Repository navigation
Expand file tree
/
Copy pathnginx.conf
More file actions
85 lines (71 loc) · 2.39 KB
/
Copy pathnginx.conf
File metadata and controls
85 lines (71 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# ============================================================
# Nginx Configuration
# ============================================================
# Serves Frontend (React) static files and proxies /api requests
# to the background Uvicorn server.
# ============================================================
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log warn;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
# Performance
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 300;
# Video files can be large (allow up to 100MB)
client_max_body_size 100M;
# Gzip compression (For frontend)
gzip on;
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript image/svg+xml;
# Upstream: Uvicorn backend
upstream backend {
server 127.0.0.1:8005;
}
server {
listen 80;
server_name _;
# ── API Requests → Uvicorn ──
location /api/ {
proxy_pass http://backend;
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;
# Video generation can take a long time
proxy_read_timeout 600s;
proxy_send_timeout 600s;
proxy_connect_timeout 30s;
# Buffer for large responses
proxy_buffering off;
}
# ── FastAPI Docs ──
location /docs {
proxy_pass http://backend;
proxy_set_header Host $host;
}
location /openapi.json {
proxy_pass http://backend;
proxy_set_header Host $host;
}
# ── Frontend Static Files ──
location / {
root /app/frontend/dist;
index index.html;
try_files $uri $uri/ /index.html;
# Cache static assets (JS/CSS/images)
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 7d;
add_header Cache-Control "public, immutable";
}
}
}
}