66 lines
1.8 KiB
Plaintext
66 lines
1.8 KiB
Plaintext
# ©AngelaMos | 2026
|
|
# vigil.conf
|
|
#
|
|
# Production nginx reverse proxy and static file server
|
|
#
|
|
# Defines an upstream to the backend on port 8000. Serves
|
|
# the Vite-built SPA from /usr/share/nginx/html with
|
|
# try_files fallback to index.html. Proxies /api/ requests
|
|
# to the backend (stripping the prefix) with standard
|
|
# forwarded headers and 30s read timeout. Proxies /ws/
|
|
# requests with HTTP 1.1 upgrade for WebSocket connections
|
|
# and 86400s read timeout. Exposes a /health endpoint
|
|
# returning 200. Enables gzip for common types and sets
|
|
# 1-year immutable cache headers on static assets. Connects
|
|
# to compose.yml, frontend Vite build output
|
|
|
|
upstream vigil_backend {
|
|
server backend:8000;
|
|
}
|
|
|
|
server {
|
|
listen 80;
|
|
server_name _;
|
|
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
|
|
gzip on;
|
|
gzip_types text/plain text/css application/json application/javascript text/xml;
|
|
gzip_min_length 256;
|
|
|
|
location / {
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
|
|
location /api/ {
|
|
proxy_pass http://vigil_backend/;
|
|
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;
|
|
}
|
|
|
|
location /ws/ {
|
|
proxy_pass http://vigil_backend/ws/;
|
|
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_read_timeout 86400s;
|
|
}
|
|
|
|
location /health {
|
|
access_log off;
|
|
return 200 'ok';
|
|
add_header Content-Type text/plain;
|
|
}
|
|
|
|
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff2?)$ {
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
}
|
|
}
|