raycer/frontend/nginx.conf

42 lines
1.4 KiB
Nginx Configuration File
Raw Permalink Normal View History

server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Don't cache the entrypoints / SW / manifest so updates roll out
location = /index.html {
add_header Cache-Control "no-cache, must-revalidate" always;
}
location = /sw.js {
add_header Cache-Control "no-cache, must-revalidate" always;
add_header Service-Worker-Allowed "/" always;
}
location = /manifest.webmanifest {
add_header Cache-Control "no-cache" always;
types { } default_type application/manifest+json;
}
# Static assets: short cache (the SW does the heavy caching)
location /css/ { add_header Cache-Control "public, max-age=300"; try_files $uri =404; }
location /js/ { add_header Cache-Control "public, max-age=300"; try_files $uri =404; }
location /icons/ { add_header Cache-Control "public, max-age=86400"; try_files $uri =404; }
# API: proxy to backend container
location /api/ {
proxy_pass http://backend:3000/api/;
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;
proxy_read_timeout 30s;
}
# SPA fallback: any other path → index.html (History API routing)
location / {
try_files $uri $uri/ /index.html;
}
}