99 lines
3.9 KiB
Plaintext
99 lines
3.9 KiB
Plaintext
server {
|
|
listen 80;
|
|
server_name aicpa.duckdns.org 13.140.170.213;
|
|
# Security Headers
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
|
add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline' 'unsafe-eval';" always;
|
|
# 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;
|
|
|
|
# ── Certbot ACME Challenge ───────────────────────────────────────────────
|
|
location /.well-known/acme-challenge/ {
|
|
root /var/www/certbot;
|
|
}
|
|
|
|
# ── 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 $remote_addr;
|
|
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 $remote_addr;
|
|
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;
|
|
}
|
|
}
|
|
|
|
|