1. The problem I’m having:
I’m serving a static website with Caddy/Docker, as follows:
In the “caddy” section of my compose.yaml
file, I have defined the volumes
volumes:
- /home/me/Docker/Caddy/Caddyfile:/etc/caddy/Caddyfile
- /home/me/Docker/Caddy/static_site:/srv
- caddy_data:/data
- caddy_config:/config
And in my Caddyfile I have
mysite.net {
root * /srv
File_server
}
This happily serves up a static website at https://mysite.net
, all files being in my server at /home/me/Docker/Caddy/static_site.
But now I want to add another static website. I have plenty of DNS subdomains to use, say static.mysite.net
. But I can’t find what I should add into my Caddyfile, and whether I need to add another volume in my compose.yaml
file. I’ve tried adding to my Caddyfile:
static.mysite.net {
root * /home/me/Docker/Caddy/another_static_site
File_server
}
with a file new_site.html
in that directory. But trying to serve that page withhttps://static.mysite.net/new_site.html
doesn’t seem to work - I just get a 404 error that the web page can’t be found.
What am I missing here? Many thanks!
2. Error messages and/or full log output:
The error is simply a 404 error that the file cannot be found.
PASTE OVER THIS, BETWEEN THE ``` LINES.
Please use the preview pane to ensure it looks nice.
3. Caddy version:
Caddy version 2.7.6
4. How I installed and ran Caddy:
I’m running Caddy as a Docker container, using Docker Compose.
a. System environment:
OS is Ubuntu Server 20.04 LT.
Docker version 25.0.1
Docker compose 2.24.2
b. Command:
docker compose up - d
or
docker restart caddy
c. Service/unit/compose file:
services:
caddy:
container_name: caddy
image: caddy:2.7.6
restart: always
ports:
- "80:80"
- "443:443"
- "443:443/udp"
networks:
- caddy_net
volumes:
- /home/me/Docker/Caddy/Caddyfile:/etc/caddy/Caddyfile
- /home/me/Docker/Caddy/static_site:/srv
- caddy_data:/data
- caddy_config:/config
- /etc/mathesar/msar/media:/code/media
- /etc/mathesar/msar/static:/code/static
(The last two lines are for the online database explorer Mathesar.)
d. My complete Caddy config:
This is the relevant bit
mysite.net {
root * /srv
File_server
}
And this is my attempt that doesn’t work:
testsite.mysite.net {
root * /home/amca/Docker/Caddy/testsite
file_server
}