nginx.conf.example 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. # HTTPS 服务器配置(使用域名)
  2. server {
  3. listen 443 ssl http2;
  4. server_name aiorz.com www.aiorz.com;
  5. # SSL 证书配置(Let's Encrypt)
  6. ssl_certificate /etc/letsencrypt/live/aiorz.com/fullchain.pem;
  7. ssl_certificate_key /etc/letsencrypt/live/aiorz.com/privkey.pem;
  8. # SSL 优化配置
  9. ssl_protocols TLSv1.2 TLSv1.3;
  10. ssl_ciphers HIGH:!aNULL:!MD5;
  11. ssl_prefer_server_ciphers on;
  12. ssl_session_cache shared:SSL:10m;
  13. ssl_session_timeout 10m;
  14. root /usr/share/nginx/aiorz-webar/;
  15. index index.html;
  16. gzip on;
  17. gzip_vary on;
  18. gzip_min_length 1024;
  19. gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
  20. location ~* \.(jpg|jpeg|png|gif|ico|css|js|svg|woff|woff2|ttf|eot)$ {
  21. expires 1y;
  22. add_header Cache-Control "public, immutable";
  23. }
  24. location / {
  25. try_files $uri $uri/ /index.html;
  26. }
  27. add_header X-Frame-Options "SAMEORIGIN" always;
  28. add_header X-Content-Type-Options "nosniff" always;
  29. add_header X-XSS-Protection "1; mode=block" always;
  30. access_log /var/log/nginx/aiorz-webar-access.log;
  31. error_log /var/log/nginx/aiorz-webar-error.log;
  32. }
  33. # HTTP 重定向到 HTTPS
  34. server {
  35. listen 80;
  36. server_name aiorz.com www.aiorz.com;
  37. return 301 https://$server_name$request_uri;
  38. }