default.conf 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. # HTTP server - 重定向到 HTTPS
  2. server {
  3. listen 80;
  4. server_name www.1919com.com 1919com.com;
  5. return 301 https://www.1919com.com$request_uri;
  6. }
  7. server {
  8. listen 443 ssl;
  9. server_name 1919com.com;
  10. return 301 https://www.1919com.com$request_uri;
  11. }
  12. server {
  13. listen 443 ssl;
  14. server_name 1919com.com;
  15. # SSL 证书配置
  16. ssl_certificate /etc/nginx/certs/9b482160a208df4e.crt;
  17. ssl_certificate_key /etc/nginx/certs/9b482160a208df4e.key;
  18. ssl_trusted_certificate /etc/nginx/certs/9b482160a208df4e.pem;
  19. # SSL 参数优化
  20. ssl_protocols TLSv1.2 TLSv1.3;
  21. ssl_prefer_server_ciphers on;
  22. ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
  23. ssl_session_cache shared:SSL:10m;
  24. ssl_session_timeout 10m;
  25. # HSTS (可选,但推荐)
  26. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
  27. # Proxy settings
  28. location / {
  29. proxy_pass http://match-vote-nextjs-nextjs-1:3000; # 使用完整的容器名称
  30. proxy_http_version 1.1;
  31. proxy_set_header Upgrade $http_upgrade;
  32. proxy_set_header Connection 'upgrade';
  33. proxy_set_header Host $host;
  34. proxy_set_header X-Real-IP $remote_addr;
  35. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  36. proxy_set_header X-Forwarded-Proto $scheme;
  37. proxy_cache_bypass $http_upgrade;
  38. # 添加超时设置
  39. proxy_connect_timeout 60s;
  40. proxy_send_timeout 60s;
  41. proxy_read_timeout 60s;
  42. }
  43. location /uploads {
  44. alias /app/public/uploads;
  45. try_files $uri $uri/ =404;
  46. add_header X-Debug-Message "$document_root$uri" always;
  47. }
  48. # 添加健康检查路由
  49. location /health {
  50. access_log off;
  51. return 200 'OK';
  52. }
  53. # Security headers
  54. add_header X-Frame-Options "SAMEORIGIN" always;
  55. add_header X-XSS-Protection "1; mode=block" always;
  56. add_header X-Content-Type-Options "nosniff" always;
  57. add_header Referrer-Policy "no-referrer-when-downgrade" always;
  58. # Gzip compression
  59. gzip on;
  60. gzip_vary on;
  61. gzip_proxied any;
  62. gzip_comp_level 6;
  63. gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
  64. # 日志格式
  65. access_log /var/log/nginx/match.dzhhzy.com.access.log;
  66. error_log /var/log/nginx/match.dzhhzy.com.error.log;
  67. }