Project

General

Profile

TVheadend behind Caddy proxy

Added by Chris Koster over 7 years ago

Hi,

I'm trying to configure TVH behind a caddy proxy (similar to nginx reverse proxy) so I have SSL enabled on the web admin. It works as much that i'm prompted to login but get a 502 bad gateway error after that. After searching on the forums i've found I have to add --http_root to the startup command of TVHeadend.

Now i'm stuck on where to add this in the init.d startup script of the tvheadend daemon? Can anyone ellaborate on this?

Many thanks in advance!


Replies (4)

RE: TVheadend behind Caddy proxy - Added by Robert Cameron about 7 years ago

Where options are passed to init scripts varies by distro. How does your particular OS handle init scripts? Runit, ignite, upstart, systemd, rc.d, OpenRC?

RE: TVheadend behind Caddy proxy - Added by Chris Koster about 7 years ago

Ah yes, i'm sorry. I'm on ubuntu 16.04 which supports systemd and rc.d

RE: TVheadend behind Caddy proxy - Added by Robert Cameron about 7 years ago

I'm not sure how Ubuntu's flavor of systemd handles this, but in gerenal your tvheadend.service unit probably has an entry in the [Service] section for EnvironmentFile=, and your ExecStart= probably references $TVH_OPTS. If that's the case, edit the file indicated in the EnvironmentFile, and add your --http_root option to the TVH_OPTS definition.

To view your systemd unit file, it's easiest to do: systemctl cat tvheadend. If your unit does not have an EnvironmentFile that it references, you can just add the definition to the ExecStart. The easiest way to do that is to use systemctl to edit the unit. Make note of your existing ExecStart, and then run systemctl edit tvheadend. This will bring up an editor (most likely nano) with an empty buffer. In there, type:

[Service]
ExecStart=
ExecStart=<Insert here the original ExecStart command> --http_root <and here you add your option>

You need the section header ([Service]) so systemd knows which part to override, and the first blank ExecStart line is necessary to blank out the command in the supplied unit file.

Another option for editing the service unit is: systemctl edit --full tvheadend, which will start the editing buffer with the full text of the unit file for you to edit, instead of just specifying lines to override.

RE: TVheadend behind Caddy proxy - Added by Jan W over 6 years ago

Hi Chris,

did you get this working? I have Tvh working behind a caddy reverse proxy. After the latest update to Tvheadend 4.3-905~g9bed2c7-dirty, I had to add the websocket preset to my Caddyfile. This is what it looks like now:

tvheadend.my.domain {
proxy / <internal-ip>:9981 {
transparent
websocket
}
}

No need to change http_root - at least in my case. Are you trying to reverse-proxy from a sub-directory - something like this?

https://your.domain/tvheadend

In my experience, it is much easiert to use sub-domains for different applications, which is no problem today thanks to Let's Encrypt.

Regards,
Jan

    (1-4/4)