浏览代码

container access

qiaofeng1227 2 年之前
父节点
当前提交
8fb83f44f9
共有 3 个文件被更改,包括 14 次插入11 次删除
  1. 1 1
      appmanage/Dockerfile
  2. 11 10
      appmanage/api/service/manage.py
  3. 2 0
      appmanage/api/utils/const.py

+ 1 - 1
appmanage/Dockerfile

@@ -10,7 +10,7 @@ COPY static ./static
 COPY requirements.txt main.py database.sqlite  ./
 COPY requirements.txt main.py database.sqlite  ./
 RUN apt update
 RUN apt update
 
 
-# Install supervisord
+# Install supervisords
 RUN apt install -y supervisor
 RUN apt install -y supervisor
 COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 COPY config/supervisord.conf /etc/supervisor/conf.d/supervisord.conf
 COPY config/cmd.sh /cmd.sh
 COPY config/cmd.sh /cmd.sh

+ 11 - 10
appmanage/api/service/manage.py

@@ -1,3 +1,4 @@
+from ast import Constant
 import os
 import os
 import io
 import io
 import sys
 import sys
@@ -791,7 +792,7 @@ def app_proxy_delete(app_id):
     customer_name = app_id.split('_')[1]
     customer_name = app_id.split('_')[1]
     proxy_host = None
     proxy_host = None
     token = get_token()
     token = get_token()
-    url = "http://172.17.0.1:9092/api/nginx/proxy-hosts"
+    url = const.NGINX_URL+"/api/nginx/proxy-hosts"
     headers = {
     headers = {
         'Authorization': token,
         'Authorization': token,
         'Content-Type': 'application/json'
         'Content-Type': 'application/json'
@@ -803,7 +804,7 @@ def app_proxy_delete(app_id):
         if customer_name == portainer_name:
         if customer_name == portainer_name:
             proxy_id = proxy["id"]
             proxy_id = proxy["id"]
             token = get_token()
             token = get_token()
-            url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
+            url = const.NGINX_URL+"/api/nginx/proxy-hosts/" + str(proxy_id)
             headers = {
             headers = {
                 'Authorization': token,
                 'Authorization': token,
                 'Content-Type': 'application/json'
                 'Content-Type': 'application/json'
@@ -844,7 +845,7 @@ def app_domain_delete(app_id, domain):
         if len(domains_old) == 0:
         if len(domains_old) == 0:
             proxy_id = proxy["id"]
             proxy_id = proxy["id"]
             token = get_token()
             token = get_token()
-            url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
+            url = const.NGINX_URL+"/api/nginx/proxy-hosts/" + str(proxy_id)
             headers = {
             headers = {
                 'Authorization': token,
                 'Authorization': token,
                 'Content-Type': 'application/json'
                 'Content-Type': 'application/json'
@@ -859,7 +860,7 @@ def app_domain_delete(app_id, domain):
         else:
         else:
             proxy_id = proxy["id"]
             proxy_id = proxy["id"]
             token = get_token()
             token = get_token()
-            url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
+            url = const.NGINX_URL+"/api/nginx/proxy-hosts/" + str(proxy_id)
             headers = {
             headers = {
                 'Authorization': token,
                 'Authorization': token,
                 'Content-Type': 'application/json'
                 'Content-Type': 'application/json'
@@ -925,7 +926,7 @@ def app_domain_update(app_id, domain_old, domain_new):
         domains_old[index] = domain_new
         domains_old[index] = domain_new
         proxy_id = proxy["id"]
         proxy_id = proxy["id"]
         token = get_token()
         token = get_token()
-        url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
+        url = const.NGINX_URL+"/api/nginx/proxy-hosts/" + str(proxy_id)
         headers = {
         headers = {
             'Authorization': token,
             'Authorization': token,
             'Content-Type': 'application/json'
             'Content-Type': 'application/json'
@@ -994,7 +995,7 @@ def app_domain_add(app_id, domain):
 
 
         proxy_id = proxy["id"]
         proxy_id = proxy["id"]
         token = get_token()
         token = get_token()
-        url = "http://172.17.0.1:9092/api/nginx/proxy-hosts/" + str(proxy_id)
+        url = const.NGINX_URL+"/api/nginx/proxy-hosts/" + str(proxy_id)
         headers = {
         headers = {
             'Authorization': token,
             'Authorization': token,
             'Content-Type': 'application/json'
             'Content-Type': 'application/json'
@@ -1028,7 +1029,7 @@ def app_domain_add(app_id, domain):
     else:
     else:
         # 追加
         # 追加
         token = get_token()
         token = get_token()
-        url = "http://172.17.0.1:9092/api/nginx/proxy-hosts"
+        url = const.NGINX_URL+"/api/nginx/proxy-hosts"
         headers = {
         headers = {
             'Authorization': token,
             'Authorization': token,
             'Content-Type': 'application/json'
             'Content-Type': 'application/json'
@@ -1127,7 +1128,7 @@ def get_proxy(app_id):
     customer_name = app_id.split('_')[1]
     customer_name = app_id.split('_')[1]
     proxy_host = None
     proxy_host = None
     token = get_token()
     token = get_token()
-    url = "http://172.17.0.1:9092/api/nginx/proxy-hosts"
+    url = const.NGINX_URL+"/api/nginx/proxy-hosts"
     headers = {
     headers = {
         'Authorization': token,
         'Authorization': token,
         'Content-Type': 'application/json'
         'Content-Type': 'application/json'
@@ -1147,7 +1148,7 @@ def get_proxy_domain(app_id, domain):
     customer_name = app_id.split('_')[1]
     customer_name = app_id.split('_')[1]
     proxy_host = None
     proxy_host = None
     token = get_token()
     token = get_token()
-    url = "http://172.17.0.1:9092/api/nginx/proxy-hosts"
+    url = const.NGINX_URL+"/api/nginx/proxy-hosts"
     headers = {
     headers = {
         'Authorization': token,
         'Authorization': token,
         'Content-Type': 'application/json'
         'Content-Type': 'application/json'
@@ -1172,7 +1173,7 @@ def get_all_domains(app_id):
     customer_name = app_id.split('_')[1]
     customer_name = app_id.split('_')[1]
     domains = []
     domains = []
     token = get_token()
     token = get_token()
-    url = "http://172.17.0.1:9092/api/nginx/proxy-hosts"
+    url = const.NGINX_URL+"/api/nginx/proxy-hosts"
     headers = {
     headers = {
         'Authorization': token,
         'Authorization': token,
         'Content-Type': 'application/json'
         'Content-Type': 'application/json'

+ 2 - 0
appmanage/api/utils/const.py

@@ -30,3 +30,5 @@ APP_STATUS_EXITED = "exited"
 APP_STATUS_RESTARTING = "restarting"
 APP_STATUS_RESTARTING = "restarting"
 # 应用错误 failed
 # 应用错误 failed
 APP_STATUS_FAILED = "failed"
 APP_STATUS_FAILED = "failed"
+
+NGINX_URL="http://websoft9-nginxproxymanager:81"