Caddy reverse proxy on QNAP

Hi @Whitestrake,

I figure that out with some more research. Thank You.

I’ve been struggling because qbittorrent dosen’t support that, so i’ve thinking what could i do:

1. I try to redirect to myurl.myqnapcloud.com:6564/qbittorrent with an index.php so that caddy could reverse the port, but i got a “bad getway” message or the page dosent load:

  • The “/qbittorrent” part i get it putting an index.php inside a “qbittorrent” folder (this folder inside web server main folder) with code to redirect me to myurl.myqnapcloud.com:6564 (qbittorrent port);

  • So when i write myurl.myqnapcloud.com/qbittorrent that index.php is pull out and i got myurl.myqnapcloud.com:6564/qbittorrent;

  • But maybe my caddyfile (caddy.conf) isn’t properly configure for this. Maybe for this i don’t need the “proxy /qbittorrent” part in caddy.conf.

2. So i saw your other post here Reverse Proxy With QBittorrent Web UI but i got “502 Bad Getway” message too:

QNAP System Configuration:

  • So like @mupet0000 i disable HTTPS in both Qnap System and Web Server. For HTTP i use port 8080 in System and 86 in Web Server;

  • I disable the built in Let’s Encrypt certificates in QNAP too;

  • All the ports are forward in the router, including 80/443 so they are free for caddy to bind. For qbittorrent i use port 6564 forward in the router too.

Caddyfile (caddy.conf):

In “/share/CACHEDEV1_DATA/.qpkg/Caddy/caddy.conf”

So my host is: myurl.myqnapcloud.com
(it runs in 8080 for http but i think caddy pull out reverse and it runs on 443 for https).

In your post as you mention for your configuration to qbittorrent: in caddyfile “The port (443 above, as I used standard HTTPS during these tests) needs to match the port shown in the browser (…)”.

I based on that and my caddy.conf is:

myurl.myqnapcloud.com {
tls email
root /home/Qhttpd/
gzip

proxy /qbittorrent http://myurl.myqnapcloud.com:6465 {
header_upstream X-Forwarded-Host {host}:443
header_upstream -Origin
header_upstream -Referer
}

proxy / localhost:8080 { # blank
transparent
header_upstream X-Forwarded-Host {host}
}

}

I’ll test this with port 8080 in "{host}: " but in order to resolve an issue i needed to reboot my nas and now i’m getting let’s encrypt rate limit errors when running caddy again. I think i need to wait a hole week to pull out renew certificates and run caddy again.

I’ll putt some research material to use built in let’s encrypt certificates with caddy because there is no much information in one place about it for qnap users i guess:

Caddy reverse proxy on QNAP-There is a way to script and auto start caddy on boot and how to renew LE certificates (I don´t know if caddy does it)

PS: Sorry for the bad english.