Feature #1427

Support reverse proxy

Added by Ronald van Eijck over 5 years ago. Updated over 5 years ago.

Status:FixedStart date:2012-11-23
Priority:NormalDue date:
Assignee:-% Done:


Category:User Interface
Target version:3.4


I've tried to create a reverse proxy in Apache to make tvheadend accessible as part of my home website but this does not seam to work.

My proxy configuration:

<Location /tvheadend>
        ProxyPass http://localhost:9981
        ProxyPassReverse http://localhost:9981

If I surf to http://myserver/tvheadend it returns to page http://myserver/extjs.html which results in a 404 because that page obviously does not exist.
It should return to http://myserver/tvheadend/extjs

I'm willing to make the needed changes if someone can point me in the right direction.

Associated revisions

Revision dd379084
Added by Adam Sutton over 5 years ago

Fix #1427 - webui: Added reverse proxy support.

This includes a next webroot command line argument (using -W) and
some minor mods to the core HTTP/WebUI code to support this. Most
of the mods are pretty trivial and hopefully nothing will break
too badly.


#1 Updated by Adam Sutton over 5 years ago

  • Category set to 11

There are quite a few places that would probably need to be edited to make it work. You also might need a root path configuration variable (though it might be easy enough to calculate it from the requests).

But this isn't actually necessary to get an apache rev proxy working. I personally maintain a small dev server that uses a single rev proxy (apache) to front a whole host of services, some of which are not "proxy friendly". But apache has options to work around this.

Unfortunately I don't have access to the machine from home so I can't provide examples at the moment.


#2 Updated by ruud - over 5 years ago

Hi, I have setup OpenVPN on my server. Using that I can access (not only) my tvheadend server from the outside world in a secure way: from my smartphone I have full access to the tvheadend web UI.
Using this solution offers the same advantages to all other functionalities on my server.
Not sure what your functional requirements for the reverse proxy are, but thought I'd share my setup :)

#3 Updated by Endre Szabo over 5 years ago

I'm making tvheadend available to SSL (certificate verified) clients with the following NGINX configuration, hope it helps:

ssl_certificate                 /etc/nginx/tvheadend.something.hu.pem;
ssl_certificate_key             /etc/nginx/tvheadend.something.hu.pem;
ssl_client_certificate          /etc/nginx/rootca.pem;
ssl_protocols                   TLSv1;
ssl_verify_client               on;
tcp_nopush                      on;
upstream tvh {
        server        ;

server {
        listen                  [::]:443;
        ssl                     on;
        server_name             tvheadend.something.hu;
        location / {
                proxy_pass http://tvh;

#4 Updated by Ronald van Eijck over 5 years ago

I've done some research on apache's mod_proxy. According to the information I found my apache proxy configuration is correct but the initial redirect from tvheadend is not according to the specifications, it returns a 302 header with a relative location (/extjs.html) where it should return a fully qualified URL, in my case http://localhost:9981/extjs.html.

The redirect call is initiated in src/webui/webui.c function page_root.
This function calls src/http.c function http_redirect

I think the http_redirect function could be rewritten to combine the supplied location (/extjs.html) with the server part of the url (in my example http://localhost:9981). I have not found out how to retrieve the server part of the url from the http_connection structure used for all http communication.

I'm also not sure if this should remain a feature request or a bug report, if the conclusion I get from the apache docs that the relocation header should contain a full URL then this is a (small) bug.

#5 Updated by Cédric Dupont over 5 years ago


I'm in the same case as Ronald. I use a main Apache vhost to get multiple access to services using ProxyPass on directory.
TVHeadEnd is not right with this. Get same error.
The point is, a lot of the others apps I run can have an option set for the contect path, so instead of running in / they can be running in /context_path/ and this make them working with apache proxy.

What Endre gives is not the same type of proxy it's a tvheadend.domain.tld and not domain.tld/tvheadend (not same use)

#6 Updated by Adam Sutton over 5 years ago

  • Status changed from New to Accepted
  • Target version set to 3.4

This is possible with Apache HTTP rewriting, I know I've had to do it before. However I couldn't figure out how to do it (easily) in nginx though I'm sure I had a go once in the past.

Anyway, since I want to now put my own TVH server behind my nginx rev proxy I thought I'd have a quick look and from what I can see the mods are pretty simple and I'll post something in a bit.


#7 Updated by Adam Sutton over 5 years ago

  • Status changed from Accepted to Fixed
  • % Done changed from 0 to 100

#8 Updated by Cédric Dupont over 5 years ago

Hi Adam,

Is the fix present in the packaged versions ?
Cannot wait to try it behind a proxy :)



#9 Updated by Adam Sutton over 5 years ago

no, its only available in master. It will be available in 3.4.


#10 Updated by Cédric Dupont over 5 years ago

Ok thank you, wait for 3.4 so

Also available in: Atom PDF