nginx-simple.conf 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # DRG系统 - 简化版 Nginx 配置(兼容 Nginx 1.14.2)
  2. # 适用于 Windows Server 2019
  3. worker_processes 1;
  4. events {
  5. worker_connections 1024;
  6. }
  7. http {
  8. include mime.types;
  9. default_type application/octet-stream;
  10. sendfile on;
  11. keepalive_timeout 65;
  12. # 如果 mime.types 不存在,取消下面的注释并手动定义类型
  13. # types {
  14. # text/html html htm shtml;
  15. # text/css css;
  16. # application/javascript js;
  17. # application/json json;
  18. # image/png png;
  19. # image/jpeg jpeg jpg;
  20. # image/gif gif;
  21. # image/svg+xml svg;
  22. # }
  23. server {
  24. listen 80;
  25. server_name localhost;
  26. # 前端静态文件根目录
  27. root html/dist;
  28. index index.html index.htm;
  29. # 启用 gzip 压缩(如果支持)
  30. # gzip on;
  31. # gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript application/javascript;
  32. # ========== 最重要的配置:API 代理 ==========
  33. location /iris-api/ {
  34. # 注意:旧版 Nginx 不支持 proxy_set_header 的某些用法
  35. proxy_pass http://172.16.2.15:52773/csp/drg/sysInternalMutiple;
  36. # 基本代理头
  37. proxy_set_header Host $host;
  38. proxy_set_header X-Real-IP $remote_addr;
  39. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  40. # 关闭缓存
  41. proxy_buffering off;
  42. # 超时设置
  43. proxy_connect_timeout 60s;
  44. proxy_send_timeout 60s;
  45. proxy_read_timeout 60s;
  46. }
  47. # 处理 React Router - 所有请求都返回 index.html
  48. location / {
  49. try_files $uri $uri/ /index.html;
  50. }
  51. # 错误页面
  52. error_page 500 502 503 504 /50x.html;
  53. location = /50x.html {
  54. root html;
  55. }
  56. }
  57. }