Reverse_proxy without base_url / subpath / prefix

1. Caddy version (caddy version):

v2.3.0 h1:fnrqJLa3G5vfxcxmOH/+kJOcunPLhSBnjgIvjXV/QTA=

2. How I run Caddy:

I am running caddy on a Rpi4 2GB. Installed with sudo apt install caddy.

a. System environment:

OS: Raspbian buster Lite
uname -a : Linux homepi 5.10.17-v7l+ #1403 SMP Mon Feb 22 11:33:35 GMT 2021 armv7l GNU/Linux

d. My complete Caddyfile:

example.duckdns.org {
        handle_path /overseerr* {
                reverse_proxy 192.168.29.2:5055
        }
}

3. The problem I’m having:

I have overseer running on docker at 192.168.29.2:5055
Overseerr doesn’t support configuring the base_url and hence I cannot simply use
reverse_proxy /overseerr/* 192.168.29.2:5055

I found the following issues on github #3266 and #2813 and as suggested I am using the above Caddyfile.

handle_path seems to strip the /overseerr in the request properly as the page is redirected to login, but the problem is that it is being redirected to https://example.duckdns.org/login instead of https://example.duckdns.org/overseerr/login. I get a blank page.

What should I do to make sure the response also contains the /overseerr subpath?

4. Error messages and/or full log output:

This is the response I get using curl -v https://example.duckdns.org/overseerr

* TLSv1.3 (IN), TLS handshake, Newsession Ticket (4):
* Connection state changed (MAX_CONCURRENT_STREAMS == 250)!
< HTTP/2 307
< date: Tue, 11 May 2021 07:08:57 GMT
< location: /login
< server: Caddy
< x-powered-by: Express
< content-length: 0
<

5. What I already tried:

I tried using handle and route with uri strip_prefix /overseerr but the same problem arises.

Use a subdomain instead like overseerr.example.duckdns.org. It’s really the only non-hacky way to make it work (and it’s a more elegant solution anyways).

See this article which explains this:

I understand that a subdomain is a better route to take but duckdns provides 5 subdomains max per account. I am already using them for other services like nextcloud. It would be a lot more convenient if there was a way to run these services on a subpath instead.

I am not sure how it can be done but is there a way to detect if the response coming from the service is changing the URL. If so maybe something can be done to ensure the URL always has the subpath prefixed to it. Maybe a rewrite rule that could do this but on the response?

No, you have unlimited. You don’t need to register a new duckdns domain, you do a subdomain of your duckdns domain. Like I wrote above, a 4th level label. DuckDNS resolves all subdomains of your registered domain to the same IP address as the main domain.

You Sir, Just made my day. I had absolutely no idea such a thing could work. Just tried it and it works like a charm.

1 Like

This topic was automatically closed after 30 days. New replies are no longer allowed.