Files
catalogue_frontend/nginx.conf
2026-08-12 16:33:39 +05:30

66 lines
2.6 KiB
Nginx Configuration File

events {}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Excel/CSV catalog uploads (see /api/upload/*) can exceed nginx's 1m default.
client_max_body_size 20m;
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
server {
listen 80;
listen 3000;
server_name localhost;
# Backend API, proxied to the FastAPI container on the same Docker
# network. proxy_pass uses a variable + Docker's embedded DNS
# (127.0.0.11) so the backend's address is re-resolved per request
# instead of cached once at nginx startup - otherwise nginx would
# keep hitting a stale IP after the backend container restarts.
resolver 127.0.0.11 valid=30s;
location /api/ {
set $backend_upstream "http://backend:8000";
proxy_pass $backend_upstream;
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;
# RAG/LLM endpoints (catalog generation, enrichment) routinely run
# well past nginx's 60s default, which would surface as a 504.
proxy_connect_timeout 30s;
proxy_send_timeout 300s;
proxy_read_timeout 300s;
}
# FastAPI's interactive docs. These are served at the app root by
# FastAPI (/docs, /redoc, /openapi.json) rather than under /api, so
# without this block they fall through to the SPA below and return
# index.html instead of Swagger.
#
# This publishes your full API surface to anyone who finds the URL.
# To close it off, delete this block and reach the docs through an SSH
# tunnel instead: ssh -L 8000:localhost:8000 user@vps
location ~ ^/(docs|redoc|openapi\.json) {
set $docs_upstream "http://backend:8000";
proxy_pass $docs_upstream;
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 / {
root /usr/share/nginx/html;
index index.html index.htm;
# This line forces Nginx to pass routing back to React Router
try_files $uri $uri/ /index.html;
}
}
}