nginx.conf.example 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # 若依前后端部署Nginx配置示例
  2. server {
  3. listen 80;
  4. server_name localhost; # 修改为您的域名或IP
  5. # 前端静态文件
  6. location / {
  7. root D:/WebApp/ruoyi-ui; # 前端打包后的dist目录
  8. index index.html index.htm;
  9. try_files $uri $uri/ /index.html;
  10. }
  11. # 后端API代理 - 关键配置
  12. location /prod-api/ {
  13. proxy_pass http://localhost:8080/prod-api/; # 后端地址
  14. proxy_set_header Host $host;
  15. proxy_set_header X-Real-IP $remote_addr;
  16. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  17. proxy_set_header X-Forwarded-Proto $scheme;
  18. # 超时设置
  19. proxy_connect_timeout 60s;
  20. proxy_send_timeout 60s;
  21. proxy_read_timeout 60s;
  22. }
  23. # 上传文件访问
  24. location /uploads/ {
  25. alias D:/WebApp/ruoyi/uploads/; # 上传文件目录
  26. autoindex on;
  27. }
  28. # 错误页面
  29. error_page 404 /index.html;
  30. error_page 500 502 503 504 /50x.html;
  31. location = /50x.html {
  32. root html;
  33. }
  34. }