File size: 2,015 Bytes
7ec3321
 
6d4d91c
 
 
 
 
 
 
 
 
 
f020d6c
 
6d4d91c
 
 
f020d6c
 
 
 
7ec3321
6d4d91c
7ec3321
 
 
 
 
 
f020d6c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# Run nginx in a way compatible with non-root Docker environments
# like Hugging Face Spaces.

# Send logs to /tmp to avoid permission issues in /var/log/nginx
error_log /tmp/error.log;
pid       /tmp/nginx.pid;

worker_processes 1;

events { 
    worker_connections 1024; 
}

http {
    # Move access logs as well
    access_log /tmp/access.log;

    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;
    sendfile      on;

    # Explicitly set paths for temporary files to /tmp
    # This prevents crashes if /var/lib/nginx/... is not writable
    client_body_temp_path /tmp/client_temp;
    proxy_temp_path       /tmp/proxy_temp;
    fastcgi_temp_path     /tmp/fastcgi_temp;
    uwsgi_temp_path       /tmp/uwsgi_temp;
    scgi_temp_path        /tmp/scgi_temp;

    # Increase timeouts for large video uploads
    client_max_body_size  250m;
    proxy_read_timeout    300s;
    proxy_send_timeout    300s;
    proxy_connect_timeout 30s;

    server {
        listen 7860;

        # ── API & WebSocket β†’ FastAPI :8000 ──────────────────────────────
        location /api/ {
            proxy_pass         http://127.0.0.1:8000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_read_timeout 300s;
        }

        location /ws/ {
            proxy_pass         http://127.0.0.1:8000;
            proxy_http_version 1.1;
            proxy_set_header   Upgrade $http_upgrade;
            proxy_set_header   Connection "Upgrade";
            proxy_set_header   Host $host;
            proxy_read_timeout 120s;
        }

        # ── Everything else β†’ Next.js :3000 ─────────────────────────────
        location / {
            proxy_pass         http://127.0.0.1:3000;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
        }
    }
}