hzdyjsweb.camasort.com.conf 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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. # SSE专用代理配置(重要:必须放在其他API配置之前)
  36. location ^~ /prod-api/resource/sse {
  37. proxy_pass http://47.121.125.41:8080/resource/sse;
  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. # SSE特殊配置
  43. proxy_http_version 1.1;
  44. proxy_set_header Connection "";
  45. proxy_buffering off;
  46. proxy_cache off;
  47. # SSE需要更长的超时时间
  48. proxy_connect_timeout 60s;
  49. proxy_send_timeout 86400s; # 24小时
  50. proxy_read_timeout 86400s; # 24小时
  51. # SSE响应头设置
  52. proxy_set_header Accept "text/event-stream";
  53. proxy_set_header Cache-Control "no-cache";
  54. proxy_set_header Connection "keep-alive";
  55. # CORS处理
  56. add_header Access-Control-Allow-Origin *;
  57. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  58. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  59. add_header Access-Control-Allow-Credentials true;
  60. if ($request_method = 'OPTIONS') {
  61. return 204;
  62. }
  63. }
  64. # SSE关闭接口专用配置
  65. location ^~ /prod-api/resource/sse/close {
  66. proxy_pass http://47.121.125.41:8080/resource/sse/close;
  67. proxy_set_header Host $host;
  68. proxy_set_header X-Real-IP $remote_addr;
  69. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  70. proxy_set_header X-Forwarded-Proto $scheme;
  71. # 普通API配置(不需要SSE特殊配置)
  72. proxy_connect_timeout 30s;
  73. proxy_send_timeout 30s;
  74. proxy_read_timeout 30s;
  75. # CORS处理
  76. add_header Access-Control-Allow-Origin *;
  77. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  78. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  79. add_header Access-Control-Allow-Credentials true;
  80. if ($request_method = 'OPTIONS') {
  81. return 204;
  82. }
  83. }
  84. # Warm-Flow工作流UI代理配置(重要:必须放在Vue路由配置之前)
  85. location ^~ /prod-api/warm-flow-ui/ {
  86. proxy_pass http://47.121.125.41:8080/warm-flow-ui/;
  87. proxy_set_header Host $host;
  88. proxy_set_header X-Real-IP $remote_addr;
  89. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  90. proxy_set_header X-Forwarded-Proto $scheme;
  91. # 支持WebSocket和SSE
  92. proxy_http_version 1.1;
  93. proxy_set_header Upgrade $http_upgrade;
  94. proxy_set_header Connection "upgrade";
  95. proxy_buffering off;
  96. proxy_cache off;
  97. # 超时设置
  98. proxy_connect_timeout 60s;
  99. proxy_send_timeout 60s;
  100. proxy_read_timeout 86400s;
  101. # CORS处理
  102. add_header Access-Control-Allow-Origin *;
  103. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  104. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  105. if ($request_method = 'OPTIONS') {
  106. return 204;
  107. }
  108. }
  109. # API代理配置(使用^~确保优先级,避免被Vue路由配置干扰)
  110. location ^~ /prod-api/ {
  111. proxy_pass http://47.121.125.41:8080/;
  112. proxy_set_header Host $host;
  113. proxy_set_header X-Real-IP $remote_addr;
  114. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  115. proxy_set_header X-Forwarded-Proto $scheme;
  116. # 支持WebSocket和SSE
  117. proxy_http_version 1.1;
  118. proxy_set_header Upgrade $http_upgrade;
  119. proxy_set_header Connection "upgrade";
  120. proxy_buffering off;
  121. proxy_cache off;
  122. # 超时设置
  123. proxy_connect_timeout 60s;
  124. proxy_send_timeout 60s;
  125. proxy_read_timeout 86400s;
  126. # CORS处理
  127. add_header Access-Control-Allow-Origin *;
  128. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS';
  129. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization,clientid';
  130. if ($request_method = 'OPTIONS') {
  131. return 204;
  132. }
  133. }
  134. # Gzip压缩配置
  135. gzip on;
  136. gzip_vary on;
  137. gzip_min_length 1024;
  138. gzip_comp_level 6;
  139. gzip_types
  140. text/plain
  141. text/css
  142. text/xml
  143. text/javascript
  144. application/json
  145. application/javascript
  146. application/xml+rss
  147. application/atom+xml
  148. image/svg+xml;
  149. # 禁止访问敏感文件
  150. location ~ /\. {
  151. deny all;
  152. access_log off;
  153. log_not_found off;
  154. }
  155. # 禁止访问备份文件
  156. location ~ ~$ {
  157. deny all;
  158. access_log off;
  159. log_not_found off;
  160. }
  161. }
  162. # HTTPS配置(可选,推荐生产环境使用)
  163. # server {
  164. # listen 443 ssl http2;
  165. # server_name hzdyjsweb.camasort.com;
  166. #
  167. # # SSL证书配置
  168. # ssl_certificate /path/to/your/certificate.crt;
  169. # ssl_certificate_key /path/to/your/private.key;
  170. #
  171. # # SSL配置
  172. # ssl_protocols TLSv1.2 TLSv1.3;
  173. # ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384;
  174. # ssl_prefer_server_ciphers off;
  175. # ssl_session_cache shared:SSL:10m;
  176. # ssl_session_timeout 10m;
  177. #
  178. # # 其他配置与HTTP相同
  179. # root /root/hzdyjsweb9091/dist;
  180. # index index.html index.htm;
  181. #
  182. # # ... 复制上面的location配置 ...
  183. # }
  184. #
  185. # # HTTP重定向到HTTPS(如果启用HTTPS)
  186. # server {
  187. # listen 80;
  188. # server_name hzdyjsweb.camasort.com;
  189. # return 301 https://$server_name$request_uri;
  190. # }