Caddy returns " domain is not served on this interface" with Docker and Traefik

I’m using Hugo Framework to play around continuous deployment. I created an image containing Caddy server, Hugo and the test project I used for my tests, sent it to my server that runs Traefik and started the image.

Here is the Dockerfile:

FROM debian:latest

RUN apt-get update -y && apt-get install git curl -y
ADD /tmp/hugo.deb
RUN dpkg -i /tmp/hugo.deb && rm /tmp/hugo.deb
RUN curl | bash -s personal
RUN chown root:root /usr/local/bin/caddy && chmod 755 /usr/local/bin/caddy
RUN mkdir /srv/app
WORKDIR /srv/app
COPY . ./
RUN git clone themes/hugo-theme-revealjs
RUN hugo
CMD ["caddy"]

And here is the “docker-compose.yml” that runs my project on my server:

  image: some_registry/my_project
    - "2015:2015"
    - ""

I almost forgot, here is my Caddyfile:

root /srv/app/public

The image runs without problem, but when reaching, I get the following message:

404 Site is not served on this interface

However, running curl http://localhost:2015 prints my project’s HTML on my server.

So… I think the problem comes from Caddy, since I have no problem when using Apache, and about 5 other of my projects use Traefik without problem.

My question is: how should I edit my Caddyfile so that I don’t have this problem?

Thank you in advance

By way of explaining what’s happening here, the first thing that should be noted is that Caddy uses the site label to match the requested Host when determining what configuration to use.

When you use the site label localhost, you’re telling Caddy to only serve that site when a client requests localhost - not, not, not the IP address.

When Traefik forwards a frontend request, it will include the requested Host. Since clients are obviously requesting the domain name, not localhost, the site label doesn’t match.

To fix it, you need to change your site label.

You could generalize it (use :2015 instead of localhost:2015), which configures Caddy to use the site definition for any hostname requested on the port. This lets you curl http://localhost:2015 AND lets Traefik get the site when requesting This is much less useful if your Caddy instance serves more than one website.

Alternately, you can adjust it to suit the Host on the incoming requests. Since we know this will always be because of the Traefik frontend rule, you’ll want to use

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