server { listen 3000; server_name _; root /usr/share/nginx/html; index index.html; # 由入口脚本写入:集群 DNS + A 站地址。用变量做 proxy_pass,启动时不解析上游,A 站暂不可达也不会让 nginx 起不来。 resolver __RESOLVER__ valid=10s ipv6=off; location = /api/health { default_type text/plain; add_header Content-Type text/plain; return 200 "ok"; } location /embed/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location /images/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location = /api/contact { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } location / { try_files $uri $uri/ /index.html; } }