server { listen 80; server_name localhost; # 前端静态文件路径 location { alias /usr/share/nginx/html; try_files $uri $uri/ /index.html; index index.html; } # API 代理到后端 location /prod-api/ { proxy_pass http://backend:8080/; 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 X-Forwarded-Proto $scheme; proxy_connect_timeout 600; proxy_read_timeout 600; } # 错误页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }