worker_processes 1; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name web.sessionzero.app; # Redirect all HTTP requests to HTTPS location / { return 301 https://$host$request_uri; } # Allow certbot challenge response location /.well-known/acme-challenge/ { root /var/www/certbot; } } server { listen 443 ssl; server_name web.sessionzero.app; root /usr/share/nginx/html; index index.html; # SSL certificates managed by Certbot ssl_certificate /etc/letsencrypt/live/web.sessionzero.app/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/web.sessionzero.app/privkey.pem; ssl_trusted_certificate /etc/letsencrypt/live/web.sessionzero.app/chain.pem; # Improve SSL configuration 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 1d; ssl_session_tickets off; ssl_stapling on; ssl_stapling_verify on; # Add HSTS header add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; location / { try_files $uri $uri/ /index.html =404; add_header 'Access-Control-Allow-Origin' '*'; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; } # Enable compression gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; # Configure caching for static assets location ~* \.(jpg|jpeg|png|gif|ico|css|js)$ { expires 1y; add_header Cache-Control "public, max-age=31536000"; } # Special handling for service worker location = /service-worker.js { expires -1; add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0"; } # Let's Encrypt challenge location location /.well-known/acme-challenge/ { root /var/www/certbot; } } }