nginx-yhm-shop-data.conf 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. # 门店检测工作台 —— nginx 反向代理配置
  2. #
  3. # 用途:把 https://yhm-shop-data.hzbeautybox.com/ 转发到本机的 127.0.0.1:8787
  4. #
  5. # 安装:
  6. # sudo cp deploy/nginx-yhm-shop-data.conf /etc/nginx/conf.d/
  7. # sudo nginx -t && sudo systemctl reload nginx
  8. #
  9. # 证书(二选一):
  10. # A. Let's Encrypt 免费证书
  11. # sudo certbot --nginx -d yhm-shop-data.hzbeautybox.com
  12. # (certbot 会自动改这个文件的 443 部分,不用手写 ssl 参数)
  13. # B. 公司已有证书 → 把下面 ssl_certificate 两行改成实际路径
  14. #
  15. # 注意:应用要以 --local 启动,只监听 127.0.0.1,不直接暴露 8787
  16. # ---------- 80:全部跳转到 HTTPS ----------
  17. server {
  18. listen 80;
  19. listen [::]:80;
  20. server_name yhm-shop-data.hzbeautybox.com;
  21. # Let's Encrypt 续期验证需要这一条
  22. location /.well-known/acme-challenge/ {
  23. root /var/www/html;
  24. }
  25. location / {
  26. return 301 https://$host$request_uri;
  27. }
  28. }
  29. # ---------- 443:正式服务 ----------
  30. server {
  31. listen 443 ssl;
  32. listen [::]:443 ssl;
  33. http2 on;
  34. server_name yhm-shop-data.hzbeautybox.com;
  35. # ---- 证书(改用 Let's Encrypt 的话把这两行替换成 certbot 生成的路径)----
  36. ssl_certificate /etc/nginx/ssl/yhm-shop-data.crt;
  37. ssl_certificate_key /etc/nginx/ssl/yhm-shop-data.key;
  38. # Let's Encrypt 默认路径:
  39. # ssl_certificate /etc/letsencrypt/live/yhm-shop-data.hzbeautybox.com/fullchain.pem;
  40. # ssl_certificate_key /etc/letsencrypt/live/yhm-shop-data.hzbeautybox.com/privkey.pem;
  41. ssl_protocols TLSv1.2 TLSv1.3;
  42. ssl_ciphers HIGH:!aNULL:!MD5;
  43. ssl_session_cache shared:SSL:10m;
  44. ssl_session_timeout 1d;
  45. # 上传 Excel 用,文件一般几百 KB,留足余量
  46. client_max_body_size 30m;
  47. # 安全响应头
  48. add_header X-Content-Type-Options nosniff always;
  49. add_header X-Frame-Options SAMEORIGIN always;
  50. add_header Referrer-Policy no-referrer-when-downgrade always;
  51. location / {
  52. proxy_pass http://127.0.0.1:8787;
  53. proxy_http_version 1.1;
  54. # 让后端知道真实来源(会话记录、日志、Secure Cookie 判断都靠这几个)
  55. proxy_set_header Host $host;
  56. proxy_set_header X-Real-IP $remote_addr;
  57. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  58. proxy_set_header X-Forwarded-Proto $scheme;
  59. # 同步接口要跑几分钟,超时给足
  60. proxy_connect_timeout 30s;
  61. proxy_send_timeout 600s;
  62. proxy_read_timeout 600s;
  63. # 导出大文件时不要缓冲到内存
  64. proxy_buffering off;
  65. }
  66. }