# earth-now.co # Author: Simon-Pierre Boucher # Contact: contact@spboucher.ai # File: infra/nginx.conf # Purpose: Reverse proxy — / → web:3000, /api|/v1|/sse|/badge → api:4000; SSE-safe (no buffering, 1 h read timeout) # # Kept portable on purpose: swapping ngrok for Cloudflare Tunnel or a plain LB # later must not require app changes. server { listen 80; server_name _; # --- API --------------------------------------------------------------- location /api { proxy_pass http://api:4000; 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; } location /v1 { proxy_pass http://api:4000; 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; } # --- SSE: model distribution — never buffer, hold connections open ------ location /sse { proxy_pass http://api:4000; 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 Connection ""; proxy_buffering off; proxy_cache off; proxy_read_timeout 1h; proxy_send_timeout 1h; chunked_transfer_encoding off; } # --- Badges: rendered by the api, CDN-cached upstream -------------------- location /badge { proxy_pass http://api:4000; proxy_http_version 1.1; proxy_set_header Host $host; proxy_set_header X-Forwarded-Proto $scheme; } # --- Everything else: Next.js web app ------------------------------------ location / { proxy_pass http://web: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"; } }