hzdyjsweb.camasort.com.conf 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. server {
  2. listen 80;
  3. server_name hzdyjsweb.camasort.com;
  4. # 网站根目录
  5. root /root/hzdyjsweb9091/dist;
  6. index index.html index.htm;
  7. # 访问日志和错误日志
  8. access_log /var/log/nginx/hzdyjsweb.camasort.com.access.log;
  9. error_log /var/log/nginx/hzdyjsweb.camasort.com.error.log;
  10. # 客户端最大上传文件大小
  11. client_max_body_size 50M;
  12. # Vue Router History模式支持 - 所有路由都指向index.html
  13. location / {
  14. try_files $uri $uri/ /index.html;
  15. # 添加安全头
  16. add_header X-Frame-Options "SAMEORIGIN" always;
  17. add_header X-Content-Type-Options "nosniff" always;
  18. add_header X-XSS-Protection "1; mode=block" always;
  19. add_header Referrer-Policy "strict-origin-when-cross-origin" always;
  20. }
  21. # 静态资源缓存配置
  22. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
  23. expires 1y;
  24. add_header Cache-Control "public, immutable";
  25. add_header Vary "Accept-Encoding";
  26. # 如果文件不存在,返回404而不是跳转到index.html
  27. try_files $uri =404;
  28. }
  29. # HTML文件缓存配置
  30. location ~* \.(html|htm)$ {
  31. expires 0;
  32. add_header Cache-Control "no-cache, no-store, must-revalidate";
  33. add_header Pragma "no-cache";
  34. }
  35. # Warm-Flow工作流UI代理配置(重要:必须放在Vue路由配置之前,使用^~确保优先级)
  36. location ^~ /prod-api/warm-flow-ui/ {
  37. proxy_pass http://47.121.125.41:8080/warm-flow-ui/;
  38. proxy_set_header Host $host;
  39. proxy_set_header X-Real-IP $remote_addr;
  40. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  41. proxy_set_header X-Forwarded-Proto $scheme;
  42. # 支持WebSocket和SSE
  43. proxy_http_version 1.1;
  44. proxy_set_header Upgrade $http_upgrade;
  45. proxy_set_header Connection "upgrade";
  46. proxy_buffering off;
  47. proxy_cache off;
  48. # 超时设置
  49. proxy_connect_timeout 60s;
  50. proxy_send_timeout 60s;
  51. proxy_read_timeout 86400s;
  52. # CORS处理
  53. add_header Access-Control-Allow-Origin *;
  54. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  55. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  56. if ($request_method = 'OPTIONS') {
  57. return 204;
  58. }
  59. }
  60. # API代理配置(使用^~确保优先级,避免被Vue路由配置干扰)
  61. location ^~ /prod-api/ {
  62. proxy_pass http://47.121.125.41:8080/;
  63. proxy_set_header Host $host;
  64. proxy_set_header X-Real-IP $remote_addr;
  65. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  66. proxy_set_header X-Forwarded-Proto $scheme;
  67. # 支持WebSocket和SSE
  68. proxy_http_version 1.1;
  69. proxy_set_header Upgrade $http_upgrade;
  70. proxy_set_header Connection "upgrade";
  71. proxy_buffering off;
  72. proxy_cache off;
  73. # 超时设置
  74. proxy_connect_timeout 60s;
  75. proxy_send_timeout 60s;
  76. proxy_read_timeout 86400s;
  77. # CORS处理
  78. add_header Access-Control-Allow-Origin *;
  79. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  80. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  81. if ($request_method = 'OPTIONS') {
  82. return 204;
  83. }
  84. }
  85. # Gzip压缩配置
  86. gzip on;
  87. gzip_vary on;
  88. gzip_min_length 1024;
  89. gzip_comp_level 6;
  90. gzip_types
  91. text/plain
  92. text/css
  93. text/xml
  94. text/javascript
  95. application/json
  96. application/javascript
  97. application/xml+rss
  98. application/atom+xml
  99. image/svg+xml;
  100. # 禁止访问敏感文件
  101. location ~ /\. {
  102. deny all;
  103. access_log off;
  104. log_not_found off;
  105. }
  106. # 禁止访问备份文件
  107. location ~ ~$ {
  108. deny all;
  109. access_log off;
  110. log_not_found off;
  111. }
  112. }
  113. # HTTPS配置(可选,推荐生产环境使用)
  114. # server {
  115. # listen 443 ssl http2;
  116. # server_name hzdyjsweb.camasort.com;
  117. #
  118. # # SSL证书配置
  119. # ssl_certificate /path/to/your/certificate.crt;
  120. # ssl_certificate_key /path/to/your/private.key;
  121. #
  122. # # SSL配置
  123. # ssl_protocols TLSv1.2 TLSv1.3;
  124. # ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
  125. # ssl_prefer_server_ciphers off;
  126. # ssl_session_cache shared:SSL:10m;
  127. # ssl_session_timeout 10m;
  128. #
  129. # # 其他配置与HTTP相同
  130. # root /root/hzdyjsweb9091/dist;
  131. # index index.html index.htm;
  132. #
  133. # # ... 复制上面的location配置 ...
  134. # }
  135. #
  136. # # HTTP重定向到HTTPS(如果启用HTTPS)
  137. # server {
  138. # listen 80;
  139. # server_name hzdyjsweb.camasort.com;
  140. # return 301 https://$server_name$request_uri;
  141. # }