server { listen 3000; server_name _; root /usr/share/nginx/html; index index.html; # 入口脚本写入集群 DNS;变量 proxy_pass 必须配合 resolver resolver __RESOLVER__ valid=10s ipv6=off; # B 站自身探针,不转发 location = /api/health { default_type text/plain; add_header Content-Type text/plain; return 200 "ok"; } # Admin + Next 静态资源 + 其余 API(含 /api/admin、/api/contact、Server Actions) location /admin { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream$request_uri; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Cookie $http_cookie; proxy_pass_header Set-Cookie; proxy_redirect __A_PUBLIC__/ /; } location /_next/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream$request_uri; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } location /api/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream$request_uri; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; proxy_set_header Cookie $http_cookie; proxy_pass_header Set-Cookie; } # 前台 embed 资源 location /embed/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream$request_uri; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } location /images/ { set $a_upstream __A_UPSTREAM__; proxy_pass $a_upstream$request_uri; proxy_http_version 1.1; proxy_ssl_server_name on; proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Real-IP $remote_addr; } location / { try_files $uri $uri/ /index.html; } }