feat: 为 Nginx 配置 Docker 内部 DNS 解析器并使用变量代理后端服务

This commit is contained in:
2026-01-28 19:54:41 +08:00
parent a28b026ed0
commit 46e5e9db00

View File

@@ -25,9 +25,13 @@ server {
add_header Cache-Control "public, immutable"; add_header Cache-Control "public, immutable";
} }
# 使用 Docker 内部 DNS 解析器
resolver 127.0.0.11 valid=30s;
# API 代理到后端 # API 代理到后端
location /api/ { location /api/ {
proxy_pass http://backend:2612; set $backend_host "backend:2612";
proxy_pass http://$backend_host;
proxy_http_version 1.1; proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade; proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade'; proxy_set_header Connection 'upgrade';
@@ -45,7 +49,8 @@ server {
# 健康检查端点 # 健康检查端点
location /health { location /health {
proxy_pass http://backend:2612/health; set $backend_host "backend:2612";
proxy_pass http://$backend_host/health;
access_log off; access_log off;
} }