36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name _; # accept any hostname (update to your domain for production)
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
# Proxy to Next.js app
|
|
location / {
|
|
proxy_pass http://app:3000;
|
|
proxy_http_version 1.1;
|
|
|
|
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;
|
|
|
|
# WebSocket support (for dev HMR; optional in production)
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "upgrade";
|
|
|
|
proxy_cache_bypass $http_upgrade;
|
|
proxy_read_timeout 86400;
|
|
}
|
|
|
|
# Static file optimization: let Nginx serve directly if mounted,
|
|
# otherwise proxied through Next.js is fine.
|
|
location /_next/static {
|
|
proxy_pass http://app:3000;
|
|
proxy_cache_valid 200 365d;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
}
|