Qbittorrent WEBUI and caddy v2

Thanks so much for taking the time to read my post and thanks for any help you give!

1. Caddy version (caddy version):

Caddy v2 (v2.2.1)

2. How I run Caddy:

I’m running Caddy with elevated windows command prompt

a. System environment:

Windows 10 20H2

b. Command:

caddy.exe start
caddy.exe stop

c. Service/unit/compose file:

NA (I think)

d. My complete Caddyfile or JSON config:

myddns.com:80 {
  respond ":-P" 403
}
myddns:443 {
  respond ":-P" 403
}
myddns.com:9100 {
  reverse_proxy 127.0.0.1:8096
}

myddns.com:10500 {
  reverse_proxy 127.0.0.1:10000 {
  header_up X-Forwarded-Host {host}:10500
  header_up -Origin
  header_up -Referer
  }
}

3. The problem I’m having:

I am trying (and failing) to hook up qbittorrent’s WEBUI with a reverse proxy via caddy v2.

4. Error messages and/or full log output:

NA

5. What I already tried:

I have forwarded port 10500 to 10000 on the server running qbittorrent; I’ve also setup the WEBUI to use port 10000.
I’ve tried to hack together a v2 caddyfile for this, using caddy v1 files as a base (e.g. Reverse Proxy With QBittorrent Web UI) and trying to update the language so its v2 compliant.

The relevant bit in my caddyfile is:

myddns.com:10500 {
  reverse_proxy 127.0.0.1:10000 {
  header_up X-Forwarded-Host {host}:10500
  header_up -Origin
  header_up -Referer
  }
}

Trying to access the WEBUI with

https://myddns.com:10000

then I reach a webpage that says ‘Unauthorized’ and nothing else.
I can confirm that I am able to reach the qbittorrent WEBUI with

192.168.1.67:10000

6. Links to relevant resources:

You can actually use {hostport} in Caddy v2. But I’m not why this would be necessary :thinking:

Maybe you can try to add header_up Host 127.0.0.1:10000 as well, since the Host header in Caddy v2 is inherited from the original request.

Either way, if that doesn’t fix it, I can try myself tonight on my Windows machine.

Amazing!

header_up Host 127.0.0.1:10000

totally worked!

I’ve also taken your other suggestion on board and my caddyfile snippet now works like this:

myddns:10500 {
  reverse_proxy 127.0.0.1:10000 {
  header_up Host 127.0.0.1:10000
  header_up X-Forwarded-Host {host}:{hostport}
  header_up -Origin
  header_up -Referer
  }
}

Thank you so much!

You misunderstood, that should be just {hostport}, because {hostport} is the host plus the port, already.

Glad it worked!

Oops. Thanks for catching my mistake.

So, just for completeness x2 (in case any one is stuck in the future) my caddyfile looks like this

myddns:10500 {
  reverse_proxy 127.0.0.1:10000 {
  header_up Host 127.0.0.1:10000
  header_up X-Forwarded-Host {hostport}
  header_up -Origin
  header_up -Referer
  }
}

Thanks again!

1 Like