How to make reverse_proxy work properly

1. Caddy version (caddy version):


2. How I run Caddy:

I have some servers, and my IP port 80 and 443 is blocked. I use NAT to serve online, But it comes out lots of NAT rules. So I created a web that contain all the services, and make just one NAT rule for this web, all services are reverse proxyed.
Services list below:

My Web with Caddy2 :

a. System environment:

Ubuntu 16.04.5 LTS

b. Command:

paste command here

c. Service/unit/compose file:

paste full file contents here

d. My complete Caddyfile or JSON config:

root * /usr/share/caddy
handle_path /emby/* {

handle_path /book/* {

handle_path /tr/* {

handle_path /sync/* {

handle_path /pve/* {

3. The problem I’m having:

1). Only EMBY works,
2). Resilio Transmission Not work, only blank page, and the url transformed with no handle_path. like or not or
3). Calibre shows :
Failed to communicate with “/book/interface-data/init?1610587317779”, with status: [400 (error)] Bad Request
The uri in the Request Line and the Authorization header do not match
4). PVE show nothing but blank page
5). all url must contain “/” like, not work.

I want any service works fine, and “/” is not necessary.

4. Error messages and/or full log output:

5. What I already tried:

6. Links to relevant resources:

Just change handle_path /emby/* to handle_path /emby* then.

For the rest, this is likely your problem:

I recommend using subdomains instead of subpaths to proxy services whenever possible.

Make sure to look at Caddy’s logs to see what’s going on, Caddy may not be connecting to your proxied services correctly.

1 Like

I do want to use subdomains, only if my server conect to the web directly.
The situation is that my caddy server is just behind my router which cannot run caddy to capture subdomains, the router only can NAT the web request, so I had to use subpaths, if you have any good advice to solve this situation, PLS DO Help me

My recommendation is to run a DNS server in your home network. CoreDNS does the job nicely for this.

Your Corefile would look something like this:

. {
    hosts {
        <caddy-server's-ip> <one-or-more-domains...>
    forward .

You can configure your router to use your server with CoreDNS installed as its DNS, and the rest of the devices on your network will inherit it.

This way, while inside your home network, the domain will resolve to the LAN IP, while outside of your network, it’ll resolve to your WAN IP.

1 Like

I’ll try, Thank you

1 Like

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