# 虚拟主机配置(前端 + 反向代理 API) server { listen 80; # 监听端口 server_name localhost; # 域名或 IP # 前端静态文件 location / { root /usr/share/nginx/html; # Vue/React 打包后的 dist 目录 index index.html; try_files $uri $uri/ /index.html; # 支持 Vue/React 前端路由 } # 后端 API 代理 location /api/ { proxy_pass http://ui-ruoyi.dawn-infinite.cn/; # 转发到后端服务 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_connect_timeout 60s; proxy_read_timeout 60s; } # 错误页面 error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } }