12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- # HTTP server - 重定向到 HTTPS
- server {
- listen 80;
- server_name www.1919com.com 1919com.com;
- return 301 https://www.1919com.com$request_uri;
- }
- server {
- listen 443 ssl;
- server_name 1919com.com;
- return 301 https://www.1919com.com$request_uri;
- }
- server {
- listen 443 ssl;
- server_name 1919com.com;
- # SSL 证书配置
- ssl_certificate /etc/nginx/certs/9b482160a208df4e.crt;
- ssl_certificate_key /etc/nginx/certs/9b482160a208df4e.key;
- ssl_trusted_certificate /etc/nginx/certs/9b482160a208df4e.pem;
- # SSL 参数优化
- ssl_protocols TLSv1.2 TLSv1.3;
- ssl_prefer_server_ciphers on;
- 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;
- ssl_session_cache shared:SSL:10m;
- ssl_session_timeout 10m;
- # HSTS (可选,但推荐)
- add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
- # Proxy settings
- location / {
- proxy_pass http://match-vote-nextjs-nextjs-1:3000; # 使用完整的容器名称
- proxy_http_version 1.1;
- proxy_set_header Upgrade $http_upgrade;
- proxy_set_header Connection 'upgrade';
- proxy_set_header Host $host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- proxy_cache_bypass $http_upgrade;
-
- # 添加超时设置
- proxy_connect_timeout 60s;
- proxy_send_timeout 60s;
- proxy_read_timeout 60s;
- }
- location /uploads {
- alias /app/public/uploads;
- try_files $uri $uri/ =404;
- add_header X-Debug-Message "$document_root$uri" always;
- }
- # 添加健康检查路由
- location /health {
- access_log off;
- return 200 'OK';
- }
- # Security headers
- add_header X-Frame-Options "SAMEORIGIN" always;
- add_header X-XSS-Protection "1; mode=block" always;
- add_header X-Content-Type-Options "nosniff" always;
- add_header Referrer-Policy "no-referrer-when-downgrade" always;
- # Gzip compression
- gzip on;
- gzip_vary on;
- gzip_proxied any;
- gzip_comp_level 6;
- gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml;
- # 日志格式
- access_log /var/log/nginx/match.dzhhzy.com.access.log;
- error_log /var/log/nginx/match.dzhhzy.com.error.log;
- }
|