Files
pwa/nginx.conf
T

62 lines
1.9 KiB
Nginx Configuration File
Raw Normal View History

server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html;
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/x-javascript application/xml+rss application/javascript application/json;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-XSS-Protection "1; mode=block" always;
# Re-resolve Docker DNS so backend IP changes after recreate don't stick as 502
resolver 127.0.0.11 valid=10s ipv6=off;
# Frontend → /api/backend/* → Hono. Variable upstream + rewrite avoids stale DNS
# and still strips the /api/backend prefix.
location /api/backend/ {
rewrite ^/api/backend/(.*)$ /$1 break;
set $backend_upstream backend:3001;
proxy_pass http://$backend_upstream;
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;
proxy_connect_timeout 5s;
proxy_read_timeout 180s;
proxy_send_timeout 180s;
}
location = /api/backend {
return 301 /api/backend/;
}
location / {
try_files $uri $uri/ /index.html;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
location ~* \.html$ {
expires -1;
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
location /health {
access_log off;
return 200 "healthy\n";
add_header Content-Type text/plain;
}
}