mattias
(Mattias)
August 18, 2021, 1:41pm
1
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:
caddy:
image: caddy
container_name: caddy
restart: unless-stopped
environment:
- CLOUDFLARE_EMAIL=${CF_MAIL}
- CLOUDFLARE_API_TOKEN=${CF_TOKEN}
ports:
- "80:80"
- "443:443"
volumes:
- ./appdata/caddy/Caddyfile:/etc/caddy/Caddyfile
- ./appdata/caddy/data:/data
- ./appdata/caddy/config:/config
networks:
- web
d. My complete Caddyfile or JSON config:
grillgeek.se
respond "Hello, grillnerd!"
sundsvallbbq.se
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.
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.
2 Likes
mattias
(Mattias)
August 19, 2021, 6:13am
3
So I created two docker images for the sites, both are started I’ve changed my Caddyfile to this:
grillgeek.se {
reverse_proxy grillgeekse:85
}
sundsvallbbq.se {
reverse_proxy sundsvallbbqse:87
}
Now I get an 502 error?
The sites work when I go to http://10.1.1.20:85 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.
2 Likes
mattias
(Mattias)
August 19, 2021, 6:25am
5
Ashamed.
They were not on the same network… thank you!
So now that this is resolved can I set up an “wildcard” subdomain?
Like:
*.domain.io {
reverese_proxy [get *_name]
}
Me being lazy.
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
mattias
(Mattias)
August 19, 2021, 8:29am
7
Great! I am looking into getting the Cloudflare plugin. Good to know!
system
(system)
Closed
September 17, 2021, 1:42pm
8
This topic was automatically closed after 30 days. New replies are no longer allowed.