Reverse proxy to almost all of my servers does not work (various problems)

So I set up a small container on Proxmox to use as a reverse proxy. Basically I just want to proxy all requests to all of my web services through this one server. I think (??) Caddy is supposed to be able to do this. Problem is, I can’t get it to proxy almost anything, and can’t figure out why some configurations work and others don’t.

I am sure I’m missing something obvious / doing something stupid because I’m new to this, but I have no idea what.

I’ll start simple. I have a PiHole DNS server. If I want to proxy requests to the server, my Caddyfile looks like this.

mydomain.net
{   
    proxy / 192.168.2.0/admin {
       transparent
    }
} 

That actually works perfectly fine. It brings up the page normally. However, if I change it to this:

mydomain.net
{   
    proxy /pihole 192.168.2.0/admin {
       transparent
    }
} 

Doesn’t work anymore. Instead of the admin page I get some generic text as if it’s not loading everything properly. If I remove the transparent option here, it looks to load up the background and text from the pihole root home page, but doesn’t load the images.

So I discovered that I need to add the “without” directive. Went ahead and did that and now this one works.

mydomain.net
{   
    proxy /pihole 192.168.2.0/admin {
       transparent
       without /pihole
    }
} 

Same situation with my simple dokuwiki. However, in this case, “without” does not work. The dokuwiki will load only if it is proxied from the root of the domain.

mydomain.net
{   
    proxy /wiki 192.168.2.2 {
       transparent
       without /wiki
    }
}

This gives me a 404, although the browser does appear to be trying to load mydomain.net/doku.php

Then I have some that just don’t work at all. For instance, if I try to proxy to my Proxmox webGUI at all, I just get 502, regardless of whether I proxy from root or a sub-directory. Proxmox I believe auto-fowards everything to https so I’m not sure if that’s a problem or not, and it also runs on an unusual port, but I tried specifying both in the config. It just 502s regardless.

mydomain.net
{   
    proxy / https://192.168.2.1:8006 {
       transparent
    }
}

Would appreciate any insight into what I’m doing wrong here.

I am having exactly the same problem! I will be very keen to hear what the solution is.

Hey all,

Check out my reply in the other thread:

In short, it has to do with the fact that your upstream servers are expecting to serve content from the web root, /, but Caddy is not configured to direct requests for the web root to the correct upstream server. You’ll find that assets such as CSS, JS, and images don’t work, and links and redirects may be broken.

The fix is to configure the upstream server to expect the subfolder (commonly referred to as a URL base), or to give unruly upstream servers their own subdomain so they can make use of the web root.

1 Like

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