Writing my first Caddy file (reverse proxy) and failing

1. Output of caddy version:

v2.5.2

2. How I run Caddy:

Docker-compose

3. The problem I’m having:

Hi!
Coming from Nginx and Traefik I now want to try out Caddy, But have a hard time to start.
I try to write a Caddyfile but already failing on the most basic thing, getting a reverse proxy running.
What I can do is overwriting the command in docker-compose.

services:
  caddy:
    container_name: caddy
    image: caddy:2-alpine
    command: caddy reverse-proxy --from https://home.fqdn.cc:443 --to http://192.168.2.12:8123

This works well but I already fail to get this fairly basic config into a caddyfile

What I would have tryed is something along these lines

home.fqdn.cc:443 {
        reverse_proxy * {
                to 127.0.0.1:8123
        }
}

But with a config like this I get something along the lines of logger":"http.log.error","msg":"dial http:: unknown network http:" .... "status":502,"err_id":"yusun417p","err_trace":"reverseproxy.statusError (reverseproxy.go:1184)"}

The big idea behind writing a caddyfile is that I want multiple services under the same subdomain.
From my not understanding point of view something like this

home.fqdn.cc:443 {
        reverse_proxy /esphome {
                to 127.0.0.1:6052
                rewrite /esphome /
        }

        reverse_proxy /otherservice {
                to 127.0.0.1:9999
                rewrite /other_thing /
        }
        reverse_proxy * {
                to 127.0.0.1:8123
        }
}

I tryed already to pull the json config and convert it back to a Caddyfile, but apperantly that is not an option

Thanks for reading
lol == Lots of Love

Welcome @kenseth!

What is your exact config? And what is the exact problem? Please also show us a request using curl -v (the exact request).

1 Like