qBittorrent Web UI -- Reverse Proxy Help

Complete Caddy noob here! I setup a reverse proxy for my URL and all of my other programs are redirecting properly, albeit they all have a reverse proxy support, except for qBittorrent. Here’s my super basic Caddyfile:

MYURL.ddns.net {
	tls `MYEMAIL@gmail.com`
	gzip

	proxy /sonarr localhost:8989 {
		transparent
		}

	proxy /qbittorrent localhost:9091 {
		transparent
		}

	proxy /radarr localhost:7878 {
		transparent
		}

	rewrite /jackett /jackett/
	proxy /jackett localhost:9117 {
		transparent
		}

	proxy /plexpy localhost:8181 {
		transparent
		}

Sonarr, Radarr, Jackett, and PlexPy are all working as expected, but when I try to access qBittorrent, it gives me an “ERR_INVALID_RESPONSE” Chrome error. When I visit it locally, or with an open port, as in “localhost:9091” or opening it up temporarily to the internet “MYURL.ddns.net:9091” it works totally fine.

Also I added the “without” argument to qBittorrent which made it show up but only in unusable plain-text. it was just a page of words.

Upon doing research, the official documentation for qBittorrent says that they support reverse proxies, and gave an example on the required lines to get it to work in NGINX. Here’s the lines to get it to work in NGINX:

    location / { 
...
        proxy_set_header    X-Forwarded-Host        $host:<webUI port>;
...
        proxy_hide_header   Referer;
        proxy_hide_header   Origin;
        proxy_set_header    Referer                 ''; 
        proxy_set_header    Origin                  ''; 
...
    }

So basically, I think I need the equivalent NGINX lines above but translated to Caddy to get it to work, which I don’t know. Can anyone translate for me? I’d love you forever!

Also I’m using the latest version of qBittorrent, v3.3.15, and I’m running everything on Windows 10.

Hi @samantonioli, welcome to the Caddy community. I’ve edited your post to put code blocks (triple backtick, ```) around your configs to preserve formatting.

My understanding is that qBittorrent doesn’t have base URL support (going off this issue). That means you’ve got three options:

  1. Continue with current subfolder setup and endure possible strange/unintended behaviour
  2. Give qBittorrent its own subdomain
  3. Have a look into http.filter and maybe this thread

However, to answer your translation question, here’s what the equivalent proxy directive block would look like in context:

proxy /qbittorrent localhost:9091 {
	header_upstream X-Forwarded-Host {host}:9091
	header_upstream Origin ''
	header_upstream Referer ''
}

https://caddyserver.com/docs/proxy
https://caddyserver.com/docs/placeholders
https://caddyserver.com/docs/http.filter

1 Like

You might also need to add without /qbittorrent to your proxy

Generally inadvisable without extra considerations, due to the fact that it merely hides the presence of the subfolder from the back end app (qBittorrent). It may result in increased functionality in cases where the app is entirely nonfunctional (i.e. no response/content) in a subfolder, but if it tries to load in CSS or JS via tags for example, those requests will come to Caddy without a prepended basepath. Caddy won’t know to send those requests to the right place and will likely 404 them, resulting in an unstyled - or unusable, depending on how script reliant it is - web page.

This is why I mention http.filter in my previous comment.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.