fix: host nginx proxies /api to gateway to avoid web DNS 502

Public HTTPS API/AI/gateway go to 127.0.0.1:8180; web only serves static. Restores static gateway upstream inside the web container.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
whm
2026-08-07 01:23:34 +08:00
parent cddf95594e
commit d489169bec
5 changed files with 55 additions and 24 deletions

View File

@@ -1,7 +1,6 @@
# 请求时解析 gateway避免启动时 DNS 未就绪导致 emerg)。
# ${NGINX_LOCAL_RESOLVERS} 由官方入口在 NGINX_ENTRYPOINT_LOCAL_RESOLVERS 开启时从 /etc/resolv.conf 注入
resolver ${NGINX_LOCAL_RESOLVERS} valid=10s ipv6=off;
# compose 生产:静态 upstream启动时解析一次)。
# 部署脚本在 gateway 就绪后 force-recreate web避免 DNS 竞态 emerg
# 公网流量优先经宿主机 Nginx 直连 gateway见 nginx/aijz.host.conf不依赖本文件反代。
server {
listen 80;
server_name _;
@@ -9,8 +8,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 +18,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 +26,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;
}