From a0f1958bf53d35c07781148fea6a2748c4c5e144 Mon Sep 17 00:00:00 2001 From: anfu Date: Fri, 13 Sep 2024 11:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95Dockerfile=E9=87=8C=E9=9D=A2?= =?UTF-8?q?=E7=9A=84env=E8=83=BD=E5=90=A6=E8=A2=AB=E8=A6=86=E7=9B=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- app/controller/Index.php | 2 +- start.php | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8ea7fc5..fd8582d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,7 +10,7 @@ RUN set -eux \ VOLUME /var/www/html ENV NACOS_ADDR="192.168.1.105:8848" \ - SERVER_ADDR="192.168.1.161:8000" + SERVICE_ADDR="192.168.1.161:8000" ADD run.sh /run.sh ADD default.conf /etc/nginx/http.d/default.conf diff --git a/app/controller/Index.php b/app/controller/Index.php index 3a3abcd..3c8ba2a 100644 --- a/app/controller/Index.php +++ b/app/controller/Index.php @@ -25,7 +25,7 @@ class Index $env = new Env(); // thinkphp里面无法获取SERVER_ADDR变量,会被nacos拦截替换 - $serverIP = $env->get('HTTP_HOST', '192.168.1.161:8000'); + $serverIP = $env->get('SERVICE_ADDR', '192.168.1.161:8000'); // 组装保存路径 $savename = \think\facade\Filesystem::disk('upload')->putFile('uploads', $file); diff --git a/start.php b/start.php index 49edae2..bb8e0ea 100644 --- a/start.php +++ b/start.php @@ -11,7 +11,7 @@ use think\Env; // 读取环境变量 $env = new Env(); // wokerman里面能准确获取SERVER_ADDR变量,没有HTTP_HOST变量 -$serverAddr = $env->get('SERVER_ADDR', '192.168.1.161:8000'); +$serverAddr = $env->get('SERVICE_ADDR', '192.168.1.161:8000'); $nacosAddr = $env->get('NACOS_ADDR', '192.168.1.105:8848'); $task = new Worker();