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:
@@ -1,5 +1,4 @@
|
||||
# Dockerfile / 非 compose 场景:静态 upstream(启动时须能解析 gateway)。
|
||||
# compose 生产请用 nginx.conf.template + NGINX_ENTRYPOINT_LOCAL_RESOLVERS。
|
||||
# Dockerfile / 非 compose:静态 upstream。
|
||||
server {
|
||||
listen 80;
|
||||
server_name _;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user