nginx-dbapp.shanxiachem.com.conf 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. # 地磅移动端 H5 - dbapp.shanxiachem.com(仅 HTTP,暂无证书)
  2. # 部署路径:/etc/nginx/conf.d/dbapp.shanxiachem.com.conf
  3. #
  4. # 静态根:/iflytek/shanxia2.0/dbapp
  5. # 访问地址:http://dbapp.shanxiachem.com
  6. # API:与 web 端相同 → 127.0.0.1:9111
  7. # 附件(MinIO bucket=ruoyi):/ruoyi/ → 127.0.0.1:9000
  8. #
  9. # 证书就绪后可再增加 listen 443 ssl 的 server 块。
  10. server {
  11. listen 80;
  12. server_name dbapp.shanxiachem.com;
  13. root /iflytek/shanxia2.0/dbapp;
  14. index index.html index.htm;
  15. client_max_body_size 50M;
  16. # access_log /iflytek/soft/nginx/nginx120/logs/dbapp-access.log main;
  17. # error_log /iflytek/soft/nginx/nginx120/logs/dbapp-error.log warn;
  18. gzip on;
  19. gzip_vary on;
  20. gzip_min_length 1024;
  21. gzip_comp_level 6;
  22. gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml application/json application/x-font-ttf font/opentype image/svg+xml;
  23. add_header X-Frame-Options "SAMEORIGIN" always;
  24. add_header X-Content-Type-Options "nosniff" always;
  25. add_header X-XSS-Protection "1; mode=block" always;
  26. # 与 web 端同一后端
  27. location ^~ /api/ {
  28. proxy_pass http://127.0.0.1:9111;
  29. proxy_set_header Host $host;
  30. proxy_set_header X-Real-IP $remote_addr;
  31. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  32. proxy_set_header X-Forwarded-Proto $scheme;
  33. proxy_set_header X-Forwarded-Port $server_port;
  34. proxy_set_header Authorization $http_authorization;
  35. proxy_pass_header Authorization;
  36. proxy_connect_timeout 60s;
  37. proxy_send_timeout 60s;
  38. proxy_read_timeout 60s;
  39. add_header Access-Control-Allow-Origin * always;
  40. add_header Access-Control-Allow-Methods 'GET, POST, PUT, DELETE, OPTIONS, PATCH' always;
  41. add_header Access-Control-Allow-Headers 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,Authorization' always;
  42. if ($request_method = 'OPTIONS') {
  43. return 204;
  44. }
  45. }
  46. # MinIO(bucket=ruoyi)
  47. location ^~ /ruoyi/ {
  48. proxy_pass http://127.0.0.1:9000;
  49. proxy_set_header Host $http_host;
  50. proxy_set_header X-Real-IP $remote_addr;
  51. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  52. proxy_set_header X-Forwarded-Proto $scheme;
  53. proxy_connect_timeout 60s;
  54. proxy_send_timeout 60s;
  55. proxy_read_timeout 60s;
  56. add_header Access-Control-Allow-Origin * always;
  57. add_header Access-Control-Allow-Methods 'GET, HEAD, OPTIONS' always;
  58. if ($request_method = 'OPTIONS') {
  59. return 204;
  60. }
  61. }
  62. location = /health {
  63. proxy_pass http://127.0.0.1:9111/health;
  64. proxy_set_header Host $host;
  65. access_log off;
  66. }
  67. location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2|ttf|eot)$ {
  68. expires 1y;
  69. add_header Cache-Control "public, immutable";
  70. try_files $uri =404;
  71. add_header Access-Control-Allow-Origin *;
  72. }
  73. location = /index.html {
  74. expires -1;
  75. add_header Cache-Control "no-store, no-cache, must-revalidate";
  76. }
  77. # Hash 路由 SPA
  78. location / {
  79. try_files $uri $uri/ /index.html;
  80. }
  81. location /health-web {
  82. access_log off;
  83. default_type text/plain;
  84. return 200 "dbapp h5 healthy\n";
  85. }
  86. location ~ /\. {
  87. deny all;
  88. access_log off;
  89. log_not_found off;
  90. }
  91. error_page 404 /index.html;
  92. error_page 500 502 503 504 /50x.html;
  93. location = /50x.html {
  94. root /iflytek/soft/nginx/nginx120/html;
  95. internal;
  96. }
  97. }