# Redirect all HTTP to HTTPS server { listen 80; server_name nexfleet.org www.nexfleet.org; return 301 https://nexfleet.org$request_uri; } # Redirect www to non-www (HTTPS) server { listen 443 ssl; server_name www.nexfleet.org; ssl_certificate /etc/letsencrypt/live/nexfleet.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/nexfleet.org/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; return 301 https://nexfleet.org$request_uri; } # Main HTTPS server (non-www) server { listen 443 ssl http2; server_name nexfleet.org; ssl_certificate /etc/letsencrypt/live/nexfleet.org/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/nexfleet.org/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # ---- 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 Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; # ---- Next.js Static Files ---- location /_next/static/ { alias /home/universities/nexfleet/.next/static/; expires 365d; access_log off; add_header Cache-Control "public, immutable, max-age=31536000"; } # ✅ Remove this section entirely: # location /assets/ { ... } # location ~* \.(ico|txt|xml|json|png|jpg|jpeg|svg|webp|gif|css|js|woff2?)$ { ... } # ---- Proxy everything else to Next.js server ---- location / { proxy_pass http://127.0.0.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_read_timeout 300; proxy_connect_timeout 300; } access_log /var/log/nginx/nexfleet.org.access.log; error_log /var/log/nginx/nexfleet.org.error.log; }