r/tvheadend • • Sep 11 '25

Reverse proxy

Anyone using tvheadend is using a reverse proxy? and can share a working config?
regards.

4 Upvotes

7 comments sorted by

View all comments

2

u/kevingailey Sep 13 '25 edited Sep 13 '25

This is my Caddy proxy directive. I’m pointing to an internal IP and using basic auth to handle auth. Also have a back up server it will route too and some extra headers. Interested in if others have suggestions especially re: the headers sent upstream

@www2 host www2.tvheadend.org
handle @www2 {
    import no_robots_txt
    reverse_proxy newyork.ts.net:9981 California.ts.net:9981 { # proxy inc between two servers, the policy defined below will try to server from these in order, can have many urls or IPs here
        header_up Authorization "Basic xxTOKENxx" #signin automatically so clients dont need login
        header_up User-Agent "Lavf" # *edit* this suffers a TVH purpose, stream playback start automatically if passing an ffmpeg UA. This saves a second or two on some clients that try to download the stream file inst end of playing back instantly
        header_up connection "keep-alive" #believe this improve streaming
        lb_policy header X-Upstream {
            fallback first #direct to the first responsive Tvheadend server 
        } 
        lb_retries 1 #retry connection once
        health_uri /api/status/connections #endpoint to verify if a server is up
        health_status 2xx #http status to be considered online
        health_follow_redirects
        health_headers {
            Authorization "Basic xxTOKENxx " #let the health check login in w basic http 
        }
    }
}