Rednote / nginx.conf
orakzai-io
Initial
194aaa5
Raw History Blame Contribute Delete
2.69 kB
# ── Production HTTPS Setup ────────────────────────────────────────
# To enable HTTPS, run certbot or use a reverse proxy like Caddy.
# Example with certbot:
# server {
# listen 443 ssl http2;
# server_name yourdomain.com;
# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# # ... copy the rest of this config below ...
# }
# server {
# listen 80;
# server_name yourdomain.com;
# return 301 https://$server_name$request_uri;
# }
# ─────────────────────────────────────────────────────────────────
server {
listen 80;
server_name _;
# Root directory for the built frontend
root /usr/share/nginx/html;
index index.html;
# Gzip compression for better performance
gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml text/javascript image/svg+xml;
gzip_min_length 256;
# Increase max body size for document uploads (matching backend MAX_FILE_SIZE: 10MB)
client_max_body_size 10M;
# ── API proxy ─────────────────────────────────────────────
# All /api/* requests are forwarded to the FastAPI backend.
# The frontend code in production should use /api/... as the
# base path (e.g., fetch('/api/chat', ...)).
location /api/ {
proxy_pass http://backend:8000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
# Timeouts for long-running streaming chat requests
proxy_read_timeout 120s;
proxy_send_timeout 120s;
# Disable buffering needed for streaming responses
proxy_buffering off;
}
# ── SPA fallback ──────────────────────────────────────────
# For any non-file, non-API route, serve index.html so React
# Router can handle client-side routing.
location / {
try_files $uri $uri/ /index.html;
}
}