server { listen 8080 default_server; server_name _; root /app/frontend/dist; index index.html; # 关闭不必要日志减少容器空间占用 access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log warn; # 前端SPA路由 - 所有非/api/路径返回index.html location / { try_files $uri $uri/ /index.html; } # 后端API代理 location /app/ { proxy_pass http://localhost:18080/app/; 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_read_timeout 60s; proxy_connect_timeout 10s; } }