Files
gw-svelte/nginx/nginx.conf
T
admin 9d87d08547 Add maintenance page served by nginx during deploys
When the SvelteKit upstream is unreachable (container restart, deploy)
nginx now serves a static, brand-styled "Be right back" page instead
of the default 502/503. Auto-reloads after 60s so visitors don't sit
on it once the app is back.

- nginx/maintenance.html: self-contained, no external assets, inline
  paw SVG, brand colours, contact details fallback
- nginx/nginx.conf: proxy_intercept_errors + error_page 502/503/504
  on both location blocks; 2s proxy_connect_timeout so nginx fails
  over fast instead of holding the connection for 60s

Deploy note: the html file needs to live at /var/www/html/maintenance.html
inside the nginx container (already mounted from /docker/wordpress/goodwalk.co.nz/html).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 08:45:48 +12:00

72 lines
2.3 KiB
Nginx Configuration File

# Redirect all HTTP to HTTPS, except ACME challenges (certbot renewal)
server {
listen 80;
server_name goodwalk.co.nz www.goodwalk.co.nz;
location /.well-known/acme-challenge/ {
root /var/www/certbot;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
server_name goodwalk.co.nz www.goodwalk.co.nz;
ssl_certificate /etc/letsencrypt/live/goodwalk.co.nz/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/goodwalk.co.nz/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers HIGH:!aNULL:!MD5;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-Frame-Options SAMEORIGIN always;
add_header X-Content-Type-Options nosniff always;
add_header Referrer-Policy strict-origin-when-cross-origin always;
gzip on;
gzip_types text/plain text/css application/javascript application/json image/svg+xml;
# Served when the SvelteKit upstream is unreachable (deploys, restarts).
# Mounted into the nginx container at /var/www/html/maintenance.html.
location = /maintenance.html {
root /var/www/html;
internal;
add_header Cache-Control "no-store" always;
}
location /api/submit {
proxy_pass http://mail-api:8000/submit;
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_intercept_errors on;
proxy_connect_timeout 2s;
error_page 502 503 504 = /maintenance.html;
}
location / {
proxy_pass http://app:3000;
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_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# Serve a static maintenance page when the app container is down/restarting,
# rather than nginx's default 502/503. The `=` keeps the original status
# code so search engines treat it as a transient outage, not a real page.
proxy_intercept_errors on;
proxy_connect_timeout 2s;
proxy_next_upstream error timeout http_502 http_503 http_504;
error_page 502 503 504 = /maintenance.html;
}
}