| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- # 若依前后端部署Nginx配置
- # 复制此内容到 C:\nginx\conf\nginx.conf 的 http 块中
- server {
- listen 80;
- server_name localhost;
- # 前端静态文件
- location / {
- root html; # 指向 C:\nginx\html(前端dist文件)
- index index.html index.htm;
- try_files $uri $uri/ /index.html;
- }
- # 后端API代理 - 关键配置
- location /prod-api/ {
- proxy_pass http://localhost:8080/prod-api/; # 代理到后端
- 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 60s;
- proxy_send_timeout 60s;
- proxy_read_timeout 60s;
- }
- # 上传文件访问
- location /uploads/ {
- proxy_pass http://localhost:8080/uploads/; # 代理到后端
- autoindex on;
- }
- # 错误页面
- error_page 404 /index.html;
- error_page 500 502 503 504 /50x.html;
- location = /50x.html {
- root html;
- }
- }
|