91 lines
2.7 KiB
Nginx Configuration File
91 lines
2.7 KiB
Nginx Configuration File
server {
|
|
listen 80;
|
|
server_name localhost;
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
# Gzip compression
|
|
gzip on;
|
|
gzip_vary on;
|
|
gzip_min_length 1024;
|
|
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
|
|
|
|
# Hashed build assets — safe to cache forever
|
|
location /assets/ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
|
|
# Other static files (icons, fonts at root etc.) — short cache
|
|
location ~* \.(png|jpg|jpeg|gif|ico|woff|woff2|ttf|eot)$ {
|
|
expires 7d;
|
|
add_header Cache-Control "public, max-age=604800";
|
|
}
|
|
|
|
# Never cache entry points — must always revalidate so clients
|
|
# can detect new frontend versions and service worker updates
|
|
location = /index.html {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
|
|
location = /sw.js {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
|
|
location = /registerSW.js {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
|
|
location = /manifest.webmanifest {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
|
|
location = /manifest.json {
|
|
add_header Cache-Control "no-cache, no-store, must-revalidate";
|
|
expires 0;
|
|
}
|
|
|
|
# WebSocket endpoint — long-lived connections need extended timeouts
|
|
location = /api/ws {
|
|
proxy_pass http://backend:8080;
|
|
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_read_timeout 86400s;
|
|
proxy_send_timeout 86400s;
|
|
}
|
|
|
|
# Proxy API requests to backend
|
|
location /api/ {
|
|
proxy_pass http://backend:8080;
|
|
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;
|
|
}
|
|
|
|
# Handle client-side routing
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
# Health check endpoint
|
|
location /health {
|
|
access_log off;
|
|
return 200 "healthy\n";
|
|
add_header Content-Type text/plain;
|
|
}
|
|
}
|