fix: web API 502 — use Podman-local DNS for gateway proxy
Mount nginx template with NGINX_LOCAL_RESOLVERS and require web→gateway health in deploy checks. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
# Podman/Docker:静态 proxy_pass 会在启动时解析 upstream;gateway 尚未进 DNS 时会 emerg 退出。
|
||||
# 变量 + resolver 改为请求时解析;127.0.0.11=Docker 内置 DNS,10.89.0.1=常见 Podman aardvark。
|
||||
resolver 127.0.0.11 10.89.0.1 valid=10s ipv6=off;
|
||||
|
||||
# Dockerfile / 非 compose 场景:静态 upstream(启动时须能解析 gateway)。
|
||||
# compose 生产请用 nginx.conf.template + NGINX_ENTRYPOINT_LOCAL_RESOLVERS。
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
@@ -9,8 +7,7 @@ server {
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_pass http://gateway:8180;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -20,8 +17,7 @@ server {
|
||||
}
|
||||
|
||||
location /ai/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_pass http://gateway:8180;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
@@ -29,8 +25,7 @@ server {
|
||||
}
|
||||
|
||||
location /gateway/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_pass http://gateway:8180;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
41
web/nginx.conf.template
Normal file
41
web/nginx.conf.template
Normal file
@@ -0,0 +1,41 @@
|
||||
# 请求时解析 gateway(避免启动时 DNS 未就绪导致 emerg)。
|
||||
# ${NGINX_LOCAL_RESOLVERS} 由官方入口在 NGINX_ENTRYPOINT_LOCAL_RESOLVERS 开启时从 /etc/resolv.conf 注入。
|
||||
resolver ${NGINX_LOCAL_RESOLVERS} valid=10s ipv6=off;
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location /api/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
client_max_body_size 64m;
|
||||
}
|
||||
|
||||
location /ai/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Authorization $http_authorization;
|
||||
client_max_body_size 64m;
|
||||
}
|
||||
|
||||
location /gateway/ {
|
||||
set $gw_upstream gateway:8180;
|
||||
proxy_pass http://$gw_upstream;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user