- Remove JWT secret fallbacks (fail on startup if missing) - Hash refresh tokens with SHA-256 before DB storage - Add Zod validation to bulk-approve, bulk-reject, update-user, copy-week - Add global API rate limiting (100 req/15min per IP) - Fix nginx X-XSS-Protection header (align with Helmet) - Remove --accept-data-loss from Dockerfile CMD - Create .gitignore to protect secrets from commits - Secure .env file permissions (chmod 600)
82 lines
2.4 KiB
Plaintext
82 lines
2.4 KiB
Plaintext
# Coastal Timesheet — Nginx reverse proxy
|
|
# /api/* → backend:3001
|
|
# /* → frontend static files
|
|
|
|
upstream backend_api {
|
|
server backend:3004;
|
|
keepalive 16;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
listen [::]:80;
|
|
server_name _;
|
|
|
|
# Security headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header X-XSS-Protection "0" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_proxied any;
|
|
gzip_comp_level 6;
|
|
gzip_min_length 256;
|
|
gzip_types
|
|
text/plain
|
|
text/css
|
|
text/xml
|
|
text/javascript
|
|
application/json
|
|
application/javascript
|
|
application/xml
|
|
application/rss+xml
|
|
image/svg+xml;
|
|
|
|
# Client body size (for file uploads if ever needed)
|
|
client_max_body_size 10m;
|
|
|
|
# ─── API proxy ───────────────────────────────────────
|
|
location /api/ {
|
|
proxy_pass http://backend_api;
|
|
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;
|
|
|
|
# Timeouts for PDF generation / email sending
|
|
proxy_read_timeout 60s;
|
|
proxy_connect_timeout 10s;
|
|
proxy_send_timeout 30s;
|
|
}
|
|
|
|
# ─── Frontend static files ───────────────────────────
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# SPA fallback — serve index.html for client-side routes
|
|
try_files $uri $uri/ /index.html;
|
|
|
|
# Cache static assets aggressively
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
access_log off;
|
|
}
|
|
}
|
|
|
|
# ─── Health check endpoint for load balancer ─────────
|
|
location = /nginx-health {
|
|
access_log off;
|
|
return 200 'ok';
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|