File size: 1,340 Bytes
c49b21b
4b5719e
 
c49b21b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b5719e
c49b21b
4b5719e
 
c49b21b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
server {
    # On Spaces Docker, the platform expects the app to listen on 7860
    listen 7860;
    
    # Increase timeouts to handle long-running operations
    proxy_connect_timeout       60s;
    proxy_send_timeout          60s;
    proxy_read_timeout          60s;
    # Temp paths are configured globally in nginx.main.conf (http scope)
    
    # Buffer settings
    proxy_buffering             on;
    proxy_buffer_size           4k;
    proxy_buffers               8 4k;
    proxy_busy_buffers_size     8k;
    
    # Client settings
    client_max_body_size        10m;
    client_body_timeout         60s;
    client_header_timeout       60s;

    # -- health-check: serve OK directly --
    location = /health {
        default_type text/plain;
        return 200 'OK\n';
        access_log off;
    }

    # -- everything else to Gradio --
    location / {
        proxy_pass       http://127.0.0.1:7860/;
        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;
        
        # Handle WebSocket upgrades for Gradio
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}