# ============================================================================= # nginx_dev.conf.template — LOCAL DEVELOPMENT config. # # WHEN IT IS USED # Rendered by nginx/entrypoint.sh whenever DEV_MODE=true, which is set only # by docker-compose.dev.yml. Never used on the Pi. # # HOW IT DIFFERS FROM nginx.conf.template # - `/` is proxied to the Vite dev server at vue:5173 instead of serving # built files from disk. The Upgrade/Connection headers on that block are # for Vite's HMR websocket, not for the app. # - No HTTP->HTTPS redirect and no apex->www redirect: BOTH :80 and :443 # serve the full site, so http://localhost just works. The two server # blocks therefore share one body, nginx_dev_common.conf.template. # - TLS uses the self-signed /etc/letsencrypt/live/localhost/ certificate that # the entrypoint generates, not a Let's Encrypt one. Browsers will warn. # - No HSTS or other security headers — HSTS on localhost would poison the # browser for every other localhost project on the machine. # - No `graphql` rate-limit zone (the production template has one); GraphQL # falls under the general `api` limit here. # - No /assets/, /fonts/, /img/ cache-control blocks: Vite serves those and # long cache lifetimes would defeat hot reload. # # TEMPLATING # Same envsubst allow-list as production. Every other dollar token is an # nginx runtime variable and must survive substitution untouched. # # INCLUDE CHAIN # this file -> nginx_dev_common.conf (once per server block: the dev-only # /uploads/ and `/` locations) -> nginx_routes.conf (the proxy route table # shared with production). The prefix-strip rewrite, the four forwarding # headers, the websocket upgrade block and the auth_request admin gate are # annotated in nginx_routes.conf.template; the rate-limit reasoning is in # nginx.conf.template. # ============================================================================= events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; server_tokens off; charset utf-8; resolver 127.0.0.11 valid=10s; client_max_body_size 50M; # These four zones are referenced by limit_req lines in the SHARED # nginx_routes.conf.template, so they must exist here with the same names # as in nginx.conf.template or nginx refuses to load the config. Rates are # kept equal to production so a limit that would bite there bites here too. limit_req_zone $binary_remote_addr zone=login:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=api:10m rate=30r/s; limit_req_zone $binary_remote_addr zone=upload:10m rate=5r/m; limit_req_zone $binary_remote_addr zone=hotel_search:10m rate=3r/m; log_format compact '$remote_addr "$request" $status rt=$request_time'; access_log /var/log/nginx/access.log compact; types { text/javascript mjs; } gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_min_length 256; gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml font/woff2 application/font-woff2; server { listen 80; server_name $DOMAIN www.$DOMAIN; include /etc/nginx/nginx_dev_common.conf; } server { listen 443 ssl; server_name $DOMAIN www.$DOMAIN; ssl_certificate /etc/letsencrypt/live/localhost/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/localhost/privkey.pem; include /etc/nginx/nginx_dev_common.conf; } }