Repository Public
1# nginx — reverse proxy in front of the Sheet web process.2# Example only: written from the application's requirements (docs/DEPLOYMENT.md §12), not taken from a running server.3#4# Replace sheet.example.org with the host of APP_URL (they must match exactly: WebAuthn compares the origin),5# the certificate paths with yours, and 127.0.0.1:8700 with the address of the web process.6# Place inside the http { } context (for example /etc/nginx/conf.d/sheet.conf).78upstream sheet_web {9 server 127.0.0.1:8700;10 keepalive 16;11}1213server {14 listen 80;15 listen [::]:80;16 server_name sheet.example.org;17 return 301 https://$host$request_uri;18}1920server {21 listen 443 ssl;22 listen [::]:443 ssl;23 http2 on;24 server_name sheet.example.org;2526 ssl_certificate /etc/letsencrypt/live/sheet.example.org/fullchain.pem;27 ssl_certificate_key /etc/letsencrypt/live/sheet.example.org/privkey.pem;28 ssl_protocols TLSv1.2 TLSv1.3;2930 # Uploads: UPLOAD_MAX_MB (default 20) plus multipart overhead. The application enforces its own cap while31 # reading the body; this limit must not be lower, and stops oversized requests earlier.32 client_max_body_size 25m;3334 # The application does not compress (next.config.ts: compress: false).35 gzip on;36 gzip_proxied any;37 gzip_types text/plain text/css application/javascript application/json application/xml application/rss+xml image/svg+xml;3839 # Common proxy settings.40 proxy_http_version 1.1;41 proxy_set_header Connection "";42 proxy_set_header Host $host;43 proxy_set_header X-Forwarded-Proto $scheme;44 # The application uses the LAST value of X-Forwarded-For (the one this proxy writes) for rate limits,45 # lock-out and the audit trail. Setting it to $remote_addr or appending with $proxy_add_x_forwarded_for both46 # put the address nginx saw last. (If another trusted proxy sits in front of nginx, use the realip module so47 # that $remote_addr is the real client.)48 proxy_set_header X-Forwarded-For $remote_addr;4950 # The web server allows 5 minutes per request.51 proxy_read_timeout 300s;52 proxy_send_timeout 300s;5354 # Security headers (CSP, HSTS, X-Frame-Options, Referrer-Policy, Permissions-Policy, nosniff) are set by the55 # application for every path. Do not add or hide them here.5657 # /render/<token> exists for the worker's headless browser, which talks to the web process directly58 # (INTERNAL_URL). Nothing outside needs it.59 location ^~ /render/ {60 return 404;61 }6263 # Job progress: server-sent events that can stay open for up to 30 minutes. No buffering, no compression,64 # long read timeout. (The application also sends "X-Accel-Buffering: no".)65 location ~ ^/api/admin/generations/[^/]+/events$ {66 proxy_pass http://sheet_web;67 proxy_buffering off;68 proxy_cache off;69 gzip off;70 proxy_read_timeout 2100s;71 }7273 # Uploads are sent straight through instead of being spooled to a temporary file first.74 location = /api/admin/assets {75 proxy_pass http://sheet_web;76 proxy_request_buffering off;77 }7879 location / {80 proxy_pass http://sheet_web;81 # Pages vary by cookie (sheet_locale) and Accept-Language: do not add proxy_cache for HTML.82 }83}84