Error 404 on my static website

1. The problem I’m having:

Trying to serve a static website (hugo) using caddyserver2
I already have 2 services running well:
portainer.officinecartografiche.net
lizmap.officinecartografiche.net

2. Error messages and/or full log output:

If I point the address to a folder like this:

www.officinecartografiche.net, officinecartografiche.net {
        root * /home/luca/docker/owncloud-docker-server/data/files/luca/files
        file_server
        encode gzip
}

I get 404 ERROR

If I try this

www.officinecartografiche.net, officinecartografiche.net {
       respond "it's working"
}

I get a correct answer

I did try changing permission on folders and also changing folder but I still get 404 error.

3. Caddy version:

Caddyserver 2

4. How I installed and ran Caddy:

I run Caddy with Docker using docker-compose.yml and Caddyfile

‘’’
GNU nano 4.8 Caddyfile
{
email luca.moiana@gmail.com
}

www.officinecartografiche.net, officinecartografiche.net {
root * /var/html
file_server
encode gzip
}

portainer.officinecartografiche.net {
reverse_proxy portainer:9000
}

cloud.officinecartografiche.net {
reverse_proxy owncloud-server:8092
}

lizmap.officinecartografiche.net {
reverse_proxy lizmap_web_1:8080
}
‘’’

a. System environment:

VPS with Ubuntu 20.04.5 LTS

How did you run Caddy exactly? What commands did you run?

Please completely fill out the help topic template as per the instructions. It’s a forum rule.

Apologies, I did added some infos

But what’s in your docker-compose file? How you run Caddy is important here.

You need to mount the files you serve in the container. Docker containers don’t have access to the files on your host unless you mount them.

do you mean I have to mount my website directory /var/www in my docker-file volumes?
For the moment my docker-file has only these 3 volumes:

‘’’
volumes:
- /home/luca/docker/caddy/Caddyfile:/etc/caddy/Caddyfile
- /home/luca/docker/caddy/data:/caddy_data # Optional
- /home/luca/docker/caddy/config:/config # Optional
‘’’

Yes. Caddy can’t read your static files from your host machine. It’s in a container. The point of containers is to isolate it from what’s on the host machine. So there’s no way to read files outside the container, unless you mount the files with a volume.

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