File Server not serving HTML file

1. Caddy version (caddy version):

Caddy 2.3.0

2. How I run Caddy:

using docker-compose

a. System environment:

Ubuntu desktop 20.04 LTS

b. Command:

sudo docker-compose up

c. Service/unit/compose file:

services:
  caddy:
    image: caddy:2.3.0
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - caddy_data:/data
      - caddy_config:/config
      - ./PubCountdown/:/home/badam/PubCountdown/
  ddns-update:
    image: ghcr.io/thedanieldoyle/ddnsupdate:latest
    restart: unless-stopped
    volumes:
      - ./ddnsConfig.json:/app/config.json

volumes:
  caddy_data:
  caddy_config:

d. My complete Caddyfile or JSON config:

http://badambox.home:80 {
    root * /home/badam/Documents/PubCountdown
    file_server browse
}

blog.parkeradam.dev {
    redir "https://parkeradam.home.blog/" permanent
}

www.blog.parkeradam.dev {
    redir "https://parkeradam.home.blog/" permanent
}

3. The problem I’m having:

When trying to navigate to badambox.home, I simply get a 404 NOT FOUND status.
I have used this endpoint prviously with a workign redirect and I have a entry in my PC’s hosts file for badambox.home

4. Error messages and/or full log output:

Unsure how to get these. If needed please instruct how to get these as adding log to caddyfile seemes to make no difference.

5. What I already tried:

  • Checking the PubCountdown file is mounted correctly by entering the container and checking location using docker run -it --rm alpine /bin/ash
  • Both removing and including the trialing ‘/’ in the volume mount, and in the Caddyfile root directive (first entry).
  • With and without ‘browse’ after file_server
  • Adding file_server { index index.html } in place of file_server
  • Removing the http and port 80 listen and trying with HTTPS

The redirect for the blog is working as expected and the ddns-update service in the docker-compose is simply an automated tool for updating DNS records whenever my external IP changes. I image it is not interferring with Caddy due to the blog redirects working.

There is a index.html file in the PubCountdown Folder. Thew index.html contains relative links to the images in the same folder. Unsure if this means anythign as I wouldve expected to still get the text.

6. Links to relevant resources:

I would provide but have unfortunatley cleaned up links I have looked at on Caddy forums and stack overflow. My apologies.

Thanks in advance for all help.

The volume mount is:

Yet the root is (note the Documents in the middle):

2 Likes

Also, I recommend placing your files in /srv instead, that’s a better location for your static files.

volumes:
  - ./PubCountdown/:/srv

In your Caddyfile:

root * /srv

If this is best practice i’ll do this. Thanks.

1 Like

This is a classic case of not seeing whats in front of your nose. Thanks :slight_smile:

1 Like

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