So what to do next to get subdomains to work?

1. Caddy version (caddy version):

Latest docker image

2. How I run Caddy:

From a docker-compose file

a. System environment:

Latest docker and latest docker-compose using version 3.9.

b. Command:

docker-compose up -d

c. Service/unit/compose file:

        image: caddy
        container_name: caddy
        restart: unless-stopped
          - "80:80"
          - "443:443"
          - ./appdata/caddy/Caddyfile:/etc/caddy/Caddyfile
          - ./appdata/caddy/data:/data
          - ./appdata/caddy/config:/config
          - web

d. My complete Caddyfile or JSON config:
respond "Hello, grillnerd!"
respond "Hello hello!"

3. The problem I’m having:

So surfing to the first URL it works, it gives the respons I have entered.
The second isnt working atm, I had made some mistakes in the Cloudflare config.

Now I want to be able to reach the services in the same docker-compose file, how do I do that?
Nextcloud, collabora, Heimdal and Minecraft.

4. Error messages and/or full log output:

None so far, everything is working. :slight_smile:

5. What I already tried:

The documentation, Google, YT, chat forums…

See the docs, this page explains how the Caddyfile is structured:

You must use braces { } for each site, if you have more than one site.


So I created two docker images for the sites, both are started I’ve changed my Caddyfile to this: {
  reverse_proxy grillgeekse:85
} {
  reverse_proxy sundsvallbbqse:87

Now I get an 502 error?
The sites work when I go to and 87

Are those the names of your containers? Are they in the same docker network as your Caddy container?

A 502 just means Caddy couldn’t connect to the upstream service.

Your post above didn’t sufficiently describe your setup, so I can only make assumptions. You’ll need to elaborate otherwise.


Ashamed. :blush:
They were not on the same network… thank you!

So now that this is resolved can I set up an “wildcard” subdomain?

* {
  reverese_proxy [get *_name]

Me being lazy. :slight_smile:

And I added anther reverese and that poited to another host, there I wasnt required to add to the same network, I know they dont have the same network to begin with just something that stuck me.

1 Like

Yes, but to use wildcards, you need to enable and configure the DNS challenge, which involves building Caddy with a plugin for your DNS provider.

ACME issuers require the DNS challenge to confirm that you have control the whole DNS zone.

If that’s too complicated for you, best to stick with listing out each subdomain.

1 Like

Great! I am looking into getting the Cloudflare plugin. Good to know!

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