diff --git a/nginx/nginx.conf b/nginx/nginx.conf index 10e62b4e..93b3b632 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -22,7 +22,7 @@ http { client_max_body_size 10M; - # Auth service + # Auth service — only direct auth endpoints location /api/auth/ { limit_req zone=api burst=10 nodelay; proxy_pass http://auth:8001/auth/; @@ -32,38 +32,7 @@ http { proxy_set_header X-Forwarded-Proto $scheme; } - # Chat API — SSE streaming needs special handling - location /api/ { - limit_req zone=api burst=20 nodelay; - proxy_pass http://chat-api:8002/api/; - 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 support - proxy_buffering off; - proxy_cache off; - proxy_read_timeout 300s; - proxy_set_header Connection ''; - chunked_transfer_encoding off; - } - - # Frontend (Next.js) - location / { - proxy_pass http://frontend:3000; - 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; - - # WebSocket support (Next.js HMR in dev, general) - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - - # Grafana (optional, if monitoring is running) + # Grafana (optional) location /grafana/ { proxy_pass http://grafana:3000/; proxy_set_header Host $host; @@ -71,5 +40,28 @@ http { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; } + + # Everything else → Frontend (Next.js) + # Next.js handles its own /api/* routes (conversations, chat/stream) + # and proxies to backend services internally via CHAT_API_URL env var + location / { + proxy_pass http://frontend:3000; + 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 streaming support + proxy_buffering off; + proxy_cache off; + proxy_read_timeout 300s; + proxy_set_header Connection ''; + chunked_transfer_encoding off; + + # WebSocket support + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } } }