qBittorrent and Caddy reverse proxy

1. Caddy version (caddy version):


2. How I run Caddy:

I am running qBittorrent using docker and I can access it via the ip locally, which works perfectly fine.

Now what I am trying to do, is access it via a subfolder on a domain that I’ll call, media.personaldomainname.com/qbittorrent.

When I add this to my config, it keeps giving me a 404 error and it shows ‘Not found’ on the screen.

If I use a sub-domain instead, it will load fine, but I am really really hoping that I can use a subfolder instead as I have many other services on this domain that use subfolders.

Any help would be extremely appreciated!

a. System environment:

Debian 11

b. Command:

caddy start

c. Service/unit/compose file:

I don't think this is applicable for me?

d. My complete Caddyfile or JSON config:

(local_only) {
	@local_subnets {
		not remote_ip
	respond @local_subnets 403

http://media.personaldomainname.com {
	handle /qbittorrent* {
		reverse_proxy localhost:8080 {
			header_up Host localhost:8080
			header_up X-Forwarded-Host {host}:8080
			header_up -X-Forwarded-For
			header_up -Origin
			header_up -Referer

3. The problem I’m having:

When I use curl -v to the subfolder, I get the following response;

C:\>curl -v media.personaldomainname.com/qbittorrent
*   Trying {IP}...
* Connected to media.personaldomainname.com ({IP}) port 80 (#0)
> GET /qbittorrent HTTP/1.1
> Host: media.personaldomainname.com
> User-Agent: curl/7.79.1
> Accept: */*
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Server: openresty
< Date: Sun, 12 Jun 2022 16:46:22 GMT
< Content-Type: text/html
< Content-Length: 166
< Connection: keep-alive
< Location: https://media.personaldomainname.com/qbittorrent
<head><title>301 Moved Permanently</title></head>
<center><h1>301 Moved Permanently</h1></center>
* Connection #0 to host media.personaldomainname.com left intact

4. Error messages and/or full log output:

Looking at the caddy logs, I don’t appear to see anything pop up that is related to this request. So I’m not sure where to look to find more information.

You’re just getting an HTTP->HTTPS redirect here. There’s no problem there.

This looks suspicious though. What’s openresty? Seems like it’s causing the redirect.

I don’t think you need any of these lines. Caddy already sets the appropriate headers.

I don’t recommend using a subpath for proxying services like this; they typically need specific support for being run under a subpath. It’s better to use a subdomain for each service. See this article for details:

1 Like