From 46e5e9db00eda1de15d897a5bc8ad0235e2c5aed Mon Sep 17 00:00:00 2001 From: 12975 <1297598740@qq.com> Date: Wed, 28 Jan 2026 19:54:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=B8=BA=20Nginx=20=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=20Docker=20=E5=86=85=E9=83=A8=20DNS=20=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=99=A8=E5=B9=B6=E4=BD=BF=E7=94=A8=E5=8F=98=E9=87=8F=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E5=90=8E=E7=AB=AF=E6=9C=8D=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nginx.conf | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nginx.conf b/nginx.conf index e858432..0195664 100644 --- a/nginx.conf +++ b/nginx.conf @@ -25,9 +25,13 @@ server { add_header Cache-Control "public, immutable"; } + # 使用 Docker 内部 DNS 解析器 + resolver 127.0.0.11 valid=30s; + # API 代理到后端 location /api/ { - proxy_pass http://backend:2612; + set $backend_host "backend:2612"; + proxy_pass http://$backend_host; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; @@ -45,7 +49,8 @@ server { # 健康检查端点 location /health { - proxy_pass http://backend:2612/health; + set $backend_host "backend:2612"; + proxy_pass http://$backend_host/health; access_log off; }