# Nginx configuration for ZMB Webui # Reverse proxy for both backend (FastAPI :8000) and frontend (Next.js :3000) upstream backend { server localhost:8000; } upstream frontend { server localhost:3000; } server { listen 9090 http2; server_name _; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Content-Type-Options "nosniff" always; add_header X-XSS-Protection "1; mode=block" always; add_header Referrer-Policy "no-referrer-when-downgrade" always; # Compression gzip on; gzip_min_length 1000; gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/json; # API routes → Backend location /api/ { proxy_pass http://backend; 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; # Timeouts proxy_connect_timeout 60s; proxy_send_timeout 60s; proxy_read_timeout 60s; } # Health check location /health { proxy_pass http://backend; proxy_http_version 1.1; access_log off; } # Frontend (Next.js) location / { proxy_pass http://frontend; 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; # Cache static assets location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { proxy_pass http://frontend; proxy_cache_valid 200 7d; add_header Cache-Control "public, max-age=604800, immutable"; } } # Logging access_log /var/log/nginx/zmb-webui-access.log combined; error_log /var/log/nginx/zmb-webui-error.log warn; }