File size: 2,278 Bytes
a93b3b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
{
    # Global options
    admin off                  # Disable admin API to avoid port conflicts
    auto_https off             # Disable automatic HTTPS (terminated by Hugging Face)
    log {
        output file /home/user/.torch_metrics/caddy.log
        format console
        level info
    }
}

# Bind to Hugging Face Spaces port 7860 and secondary port 7890
:7860, :7890 {
    # --- Static asset serving (served directly from disk, no Python involved) ---
    handle /static/* {
        root * /home/user/static
        file_server
    }

    # Chisel tunnel (strips prefix)
    handle_path /chisel-tunnel* {
        reverse_proxy 127.0.0.1:6789
    }

    # Gost bridge (retains prefix)
    reverse_proxy /gost-bridge* 127.0.0.1:6790

    # Model sync (strips prefix)
    handle_path /model-sync* {
        reverse_proxy 127.0.0.1:6795
    }

    # Tensor mesh / Sliver (removes cert validation for self-signed backend)
    reverse_proxy /tensor-mesh* https://127.0.0.1:11601 {
        transport http {
            tls_insecure_skip_verify
        }
    }

    # LiteLLM OpenAI API proxy and health check (retains prefix)
    reverse_proxy /v1* 127.0.0.1:8080
    reverse_proxy /health* 127.0.0.1:8080

    # Routing console / Filebrowser (retains prefix)
    reverse_proxy /routing-console* 127.0.0.1:6801

    # Visual debugger interface (strips prefix)
    handle_path /visual-debugger* {
        reverse_proxy 127.0.0.1:6080
    }

    # Default: route all other public traffic to Gradio (port 7861)
    handle {
        reverse_proxy 127.0.0.1:7861 {
            # Inform Gradio of the real scheme so it generates https:// asset URLs.
            # Without these, Gradio sees a plain HTTP upstream connection and emits
            # http:// links which browsers block as mixed content.
            header_up X-Forwarded-Proto https
            header_up X-Forwarded-Host  {host}
        }
    }

    # --- Upstream error interception (served from disk, Python runtime unburdened) ---
    # During Gradio boot, any 502/503/504 from the upstream proxy is caught here
    # and the branded loading page is streamed directly off disk by Caddy.
    handle_errors 502 503 504 {
        root * /home/user/static
        rewrite * /loading.html
        file_server
    }
}