Some config files for the NginX web server & reverse proxy server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.6 KiB

  1. # Example configuration for a www-subdomain
  2. # Redirect www http traffic to www https
  3. server{
  4. listen 80;
  5. server_name www.YOURSITEDOMAIN.com;
  6. return 301 https://www.YOURSITEDOMAIN.com$request_uri;
  7. }
  8. # Redirect non-www http traffic to www https
  9. server {
  10. listen 80;
  11. server_name YOURSITEDOMAIN.com;
  12. return 301 https://www.YOURSITEDOMAIN.com$request_uri;
  13. }
  14. # Redirect non-www https traffic to www https
  15. server {
  16. listen 443;
  17. server_name YOURSITEDOMAIN.com;
  18. return 301 https://www.YOURSITEDOMAIN.com$request_uri;
  19. # SSL configuration
  20. ssl_certificate /etc/letsencrypt/live/YOURSITEDOMAIN.com/fullchain.pem;
  21. ssl_certificate_key /etc/letsencrypt/live/YOURSITEDOMAIN.com/privkey.pem;
  22. ssl on;
  23. ssl_session_cache builtin:1000 shared:SSL:10m;
  24. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  25. ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
  26. ssl_prefer_server_ciphers on;
  27. }
  28. # Main server block for www https
  29. server {
  30. listen 443;
  31. server_name www.YOURSITEDOMAIN.com;
  32. # SSL configuration
  33. ssl_certificate /etc/letsencrypt/live/YOURSITEDOMAIN.com/fullchain.pem;
  34. ssl_certificate_key /etc/letsencrypt/live/YOURSITEDOMAIN.com/privkey.pem;
  35. ssl on;
  36. ssl_session_cache builtin:1000 shared:SSL:10m;
  37. ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  38. ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
  39. ssl_prefer_server_ciphers on;
  40. # Set the access log location
  41. access_log /var/log/nginx/YOURSITEDOMAIN.access.log;
  42. location / {
  43. # Set the proxy headers
  44. proxy_set_header Host $host;
  45. proxy_set_header X-Real-IP $remote_addr;
  46. proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  47. proxy_set_header X-Forwarded-Proto $scheme;
  48. # Configure which address the request is proxied to
  49. proxy_pass http://YOURSERVER:YOURPORT;
  50. proxy_read_timeout 90;
  51. proxy_redirect http://YOURSERVER:YOURPORT https://www.YOURSITEDOMAIN.com;
  52. # Set the security headers
  53. add_header Permissions-Policy "interest-cohort=()"; # Don't allow Google FLoC
  54. add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"; #HSTS
  55. add_header X-Frame-Options DENY; #Prevents clickjacking
  56. add_header X-Content-Type-Options nosniff; #Prevents mime sniffing
  57. add_header X-XSS-Protection "1; mode=block"; #Prevents cross-site scripting attacks
  58. add_header Referrer-Policy "origin"; #Idk what this actually does
  59. # Rewrite all URI's so they have a trailing slash
  60. rewrite ^([^.]*[^/])$ $1/ permanent;
  61. }
  62. }