Struggle defining a simple configuration

So, for a bit of context, I dockerized / demonized a Hugo static website, and now I’m trying to make it run from the image.

If this is relevant at all, here is my Dockerfile:

FROM debian:stretch

RUN apt-get -qq update \
	&& DEBIAN_FRONTEND=noninteractive apt-get -qq install -y --no-install-recommends git curl ca-certificates asciidoc \
	&& rm -rf /var/lib/apt/lists/*

RUN curl --silent --show-error --fail --location \
      --header "Accept: application/tar+gzip, application/x-gzip, application/octet-stream" -o - \
      "https://caddyserver.com/download/linux/amd64?plugins=http.expires,http.realip&license=personal" \
    | tar --no-same-owner -C /usr/bin/ -xz caddy \
    && chmod 0755 /usr/bin/caddy \
    && /usr/bin/caddy -version \

ENV HUGO_VERSION 0.42.1
ENV HUGO_BINARY hugo_${HUGO_VERSION}_Linux-64bit.deb

ADD https://github.com/gohugoio/hugo/releases/download/v0.42.2/hugo_0.42.2_Linux-64bit.deb /tmp/hugo.deb
RUN dpkg -i /tmp/hugo.deb \
	&& rm /tmp/hugo.deb

COPY ./Caddyfile /etc/Caddyfile

COPY . /srv/app
WORKDIR /srv/app
RUN chown -R www-data:www-data /srv/app
RUN hugo
CMD ["/usr/bin/caddy", "--conf", "/etc/Caddyfile", "--log", "stdout"]

And here is my Caddyfile:

localhost
root /srv/app/public

According to this website, who told me that I didn’t need anything else

https://novelist.xyz/tech/caddy-webserver/

I can successfully build my image without any problem, and here is the output of Caddy:

Attaching to hugodelire_web_1
web_1 | Activating privacy features… done.
web_1 | http://localhost:2015
web_1 | 2018/06/30 10:30:21 http://localhost:2015

However, trying to reach “localhost”, “localhost:2015” or “localhost:8080” will either return “connection refused” or “connection reset”

What am I missing?

Thank you in advance

Your ports 80 and 443 may be blocked externally.

Did you try visiting your website on that server with a tool like lynx or something similar?

Doesn’t look like ports 80 or 443 are involved at all. Port 2015 is the default, and it hasn’t been changed (not by manual Caddyfile specification nor by eligibility for Automatic HTTPS).

@Jaeger767, did you map ports from the Docker container to the Docker host in your docker run command?

If so, which ports did you map?

If not, you will find that once you figure out how to access your Docker container (by the container IP address and port, most likely), Caddy will return “Site not served on this interface” because you’ve configured it to respond only to localhost.

I figured it out, and I realized I was mapping a docker-compose file (not shown in my question to output the “8080” port, while Caddy was showing the 2015 port. Everything worked well after that, thank you both for your answers

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