91 lines
3.3 KiB
Plaintext
91 lines
3.3 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name aiindiacpa.duckdns.org 147.93.168.145;
|
|
|
|
|
|
|
|
# Redirect all HTTP traffic to HTTPS (uncomment when SSL certs are generated)
|
|
# location / {
|
|
# return 301 https://$host$request_uri;
|
|
# }
|
|
|
|
# Max upload size — matches backend 10MB limit with buffer
|
|
client_max_body_size 15m;
|
|
|
|
# ── Static CSS (served directly from dist, no FastAPI hop) ───────────────
|
|
location /css/ {
|
|
root /usr/share/nginx/html;
|
|
expires 7d;
|
|
add_header Cache-Control "public, no-transform";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# ── Vite JS/CSS bundle assets (hashed filenames — cache forever) ─────────
|
|
location /assets/ {
|
|
root /usr/share/nginx/html;
|
|
expires 1y;
|
|
add_header Cache-Control "public, immutable";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# ── Static images served from dist ───────────────────────────────────────
|
|
location /images/ {
|
|
root /usr/share/nginx/html;
|
|
expires 7d;
|
|
add_header Cache-Control "public, no-transform";
|
|
try_files $uri =404;
|
|
}
|
|
|
|
# ── Favicon and root-level static files ──────────────────────────────────
|
|
location = /favicon.svg {
|
|
root /usr/share/nginx/html;
|
|
expires 7d;
|
|
}
|
|
location = /icons.svg {
|
|
root /usr/share/nginx/html;
|
|
expires 7d;
|
|
}
|
|
|
|
# ── User-uploaded files (documents stored on VPS disk) ───────────────────
|
|
# Proxied through FastAPI for auth token validation — never served directly
|
|
location /api/upload/file/ {
|
|
proxy_pass http://app:8000;
|
|
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;
|
|
# Allow larger responses for file downloads
|
|
proxy_buffering off;
|
|
proxy_read_timeout 120s;
|
|
}
|
|
|
|
# ── All API routes → FastAPI ──────────────────────────────────────────────
|
|
location /api/ {
|
|
proxy_pass http://app:8000;
|
|
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_read_timeout 60s;
|
|
proxy_send_timeout 60s;
|
|
}
|
|
|
|
# ── Health check (bypass FastAPI for load balancer pings) ────────────────
|
|
location = /health {
|
|
proxy_pass http://app:8000;
|
|
proxy_set_header Host $host;
|
|
}
|
|
|
|
# ── SPA fallback — serve index.html for all other routes ─────────────────
|
|
# React Router handles the actual routing client-side
|
|
location / {
|
|
root /usr/share/nginx/html;
|
|
index index.html;
|
|
try_files $uri $uri/ /index.html;
|
|
}
|
|
}
|
|
|
|
|