Reverse proxy to another caddy server

1. Caddy version (caddy version):

2.2.1

2. How I run Caddy:

via docker compose

a. System environment:

b. Command:

paste command here

c. Service/unit/compose file:

on both machines more or less like this

caddy:
    image: caddy:2.2.1-alpine
    restart: unless-stopped
    container_name: caddy
    ports:
      - "80:80"
      - "443:443"
      - "2019:2019"
    volumes:
      - /dockerdata/stuff/media/config/caddy/Caddyfile:/etc/caddy/Caddyfile
      - /dockerdata/stuff/media/data/caddy/site:/srv
      - /dockerdata/stuff/media/data/caddy:/data
      - /dockerdata/stuff/media/config/caddy:/config

d. My complete Caddyfile or JSON config:

http://192.168.5.44 {

reverse_proxy /sonarr* http://sonarr:8989
reverse_proxy /transmission* http://transmission:9091
reverse_proxy /radarr* http://radarr:7878
reverse_proxy /bazarr* http://bazarr:6767
reverse_proxy /jellyfin* http://jellyfin:8096
reverse_proxy /hydra* http://hydra:5076
reverse_proxy * http://heimdall:80
}

subdomain1.example.com {

reverse_proxy /sonarr* http://sonarr:8989
reverse_proxy /transmission* http://transmission:9091
reverse_proxy /radarr* http://radarr:7878
reverse_proxy /bazarr* http://bazarr:6767
reverse_proxy /jellyfin* http://jellyfin:8096
reverse_proxy /hydra* http://hydra:5076
reverse_proxy * http://heimdall:80
}

on the other machine i tried both https and http, ports 80 and 443

subdomain1.example.com {
	reverse_proxy http://192.168.5.44
}

3. The problem I’m having:

I’m trying to have all my requests go through one port to 1 vm which then sends those requests to other vms, in this example to another caddy server who proxies it to some docker apps. Currently with just the first Caddyfile and port forwarded to that vm everything works.

There are no errors, the web browser is just not opening anything.

5. What I already tried:

I tried to add
header_up Host {http.reverse_proxy.upstream.hostport}
but there was no change.

Sorry if i explained it badly, i don’t have much experience with networks.

Please upgrade to v2.3.0!

You don’t need this unless you’re exposing the admin API

Which of those two Caddyfiles is the one that’s publicly accessible?

To be honest, i’m not even sure why’m not using the latest tag.

Currently the first one is public but i want to make this one(the second one) the public one and then depending on the subdomain proxy it to the vm that i want
subdomain1.example.com { reverse_proxy http://192.168.5.44 }

It’s better not to use latest so that you’re deliberately upgrading versions. If there’s breaking changes in new versions of Caddy (which happens not infrequently) then it forces you to actually make sure it works with a person at the computer instead of it upgrading and having errors due to incompatible changes.

Okay, then the config for the one behind the other should have a config like this:

:80 {
	...
}

Then you can proxy to it with any hostname on port 80 and it should work.

Thank you, it works now, i was trying different configs on the wrong one.

1 Like

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