Docker containers & custom local domain

1. My Caddy version (caddy version):

docker caddy/caddy (v2)

2. How I run Caddy:

Using docker on my linux server. I also have dnsMasq running on my router, so requests for my custom “home” domain are redirected there.

a. System environment:


b. Command:

docker compose up -d

c. Compose file:

version: "3.7"

    image: "caddy/caddy"
    container_name: "caddy"
    hostname: "caddy"
    restart: unless-stopped
      - "80:80"
      - "443:443"
      - MY_DOMAIN
      - ./Caddyfile:/etc/caddy/Caddyfile:ro
      - ./data:/data
      - ./config:/config
      name: $DEFAULT_NETWORK

d. My complete Caddyfile or JSON config:

http://a.home {
    reverse_proxy / {

3. The problem I’m having:

I must preface this : I’m a huge newbie, I have little to zero IT background, so please forgive me if what I’m asking is absurd.

I’m running several services in docker containers for my personal use at home. For example, I have Nodered running and I can access it at

Since I have many services, I often get confused by urls. First world problem I know, but in any case I’d like to solve the issue using http://nodered.home instead of the current address.

Before posting here, I’ve googled my issue many times, but there seems to be as many approches as there are people posting about similar issues … and I’m getting confused.

Now, I have setup my router as such it redirects the request made to domain “home” to my server (

With caddy running I cand do $ curl http://a.home and it gives me

<!DOCTYPE html>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="mobile-web-app-capable" content="yes">

So I guess this is a good sign … until I try using my laptop (chrome) and I get a ERR_CONNECTION_REFUSED error when typing http://a.home. I can still access my container using

4. Error messages and/or full log output:

    2020/05/06 10:18:52 [INFO][cache:0xc000018140] Started certificate maintenance routine
{"level":"info","ts":1588760332.583447,"logger":"http","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
{"level":"info","ts":1588760332.584713,"logger":"tls","msg":"cleaned up storage units"}
{"level":"info","ts":1588760332.5852015,"msg":"autosaved config","file":"/config/caddy/autosave.json"}
{"level":"info","ts":1588760332.5852308,"msg":"serving initial configuration"}

5. What I already tried:

  • Using docker service name instead of the IP (ex: nodered:1880 instead of
  • Making sure that I’m not using https to avoid errors linked to the custom domain name.
  • Read posts on this forum about similar cases.
  • Googled the issue several times.

Does my problem makes sense ? What am I missing if that’s the case ?

Thanks for any help you can provide !

FYI I think you should just use image: caddy here, because we have an official image now available.

I think the config you’re looking for is:

http://a.home {

If you specify / as your matcher, than Caddy would only handle requests to the root of your site. Instead if you omit a matcher, then it instead is the same as *, as in “match all paths”. In Caddy v2, path matchers are exact-match which is a difference from Caddy v1 which used prefix-matching for paths.

I’m unsure if that’s the only thing going wrong for you here, but we can try to narrow things down further if that doesn’t fix it.

1 Like

Thanks a lot for your answer !
I’ve modified my compose file following your remark, so I guess that’s an improvement.

However, even with the modifications applied to CaddyFile (container recreated, and restarted) the issue remains : I get an answer with curl from a remote session on my server, but still a connection error from chrome on my laptop.

A shot in the dark here, but I’m also running pihole on my server, and it acts as a DNS server :

Router settings

Can this be related, since I can curl successfully from the same IP, but get an error when I make a request from another (sorry if the terms are incorrect) ?

Yep. It’s always DNS.

Update : The solution described by @francislavoie is working. At least it is for now. I did not change anything since my previous message yesterday (at which time I still had this connection error issue) … and now it’s working as intended this morning. I was also able to add more urls to my CaddyFile and they are working as well (I was worried that this was just a delay issue with caddy afterall).

So, I’m very happy with the fact that it’s now ok, so thank you all for your help !
What I’m not so happy about is that I still don’t understand why this is fixed … and I just realized I need https for bitwarden, but that’s a story for another day ^^.



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