File size: 1,860 Bytes
2a081e2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52013b5
2a081e2
 
 
 
 
 
 
 
 
 
3dc8487
 
aa42ffe
 
 
 
 
3dc8487
 
efe59e5
 
 
 
 
 
 
 
 
52013b5
2a081e2
 
 
 
 
 
 
 
 
 
 
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
worker_processes 1;
pid /tmp/nginx.pid;
error_log /tmp/nginx-error.log warn;

events {
    worker_connections 256;
}

http {
    access_log off;
    client_body_temp_path /tmp/nginx-body;
    proxy_temp_path /tmp/nginx-proxy;
    fastcgi_temp_path /tmp/nginx-fastcgi;
    uwsgi_temp_path /tmp/nginx-uwsgi;
    scgi_temp_path /tmp/nginx-scgi;

    map $http_upgrade $connection_upgrade {
        default upgrade;
        '' close;
    }

    server {
        listen 7860;

        # /ssh → WebSocket-to-SSH bridge
        location /ssh {
            proxy_pass http://127.0.0.1:7862;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
            proxy_read_timeout 86400;
            proxy_send_timeout 86400;
        }

        # /runlog → full log file (static)
        location = /runlog {
            default_type text/plain;
            add_header Cache-Control "no-cache, no-store";
            alias /var/log/huggingrun.log;
        }

        # /runlog/stream → SSE real-time log stream
        location /runlog/stream {
            proxy_pass http://127.0.0.1:7863/stream;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            proxy_buffering off;
            proxy_cache off;
            chunked_transfer_encoding off;
            proxy_read_timeout 86400;
        }

        # Everything else → ttyd web terminal
        location / {
            proxy_pass http://127.0.0.1:7681;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
            proxy_read_timeout 86400;
            proxy_send_timeout 86400;
        }
    }
}