Caddyfile for Hugo website with Caddy2

1. The problem I’m having:

I want to use Caddy2 to show my web site with Hugo
I already create my hugo public folder, this folder’s path is /home/ubuntu/public.
I already install Caddy2
Then I edit the /etc/caddy/Caddyfile for show it.
Here is my Caddyfile

:80 {
        # Set this path to your site's directory.
        # root * /usr/share/caddy  ==> default 
        # root * /usr/share/pubic   ==> this one work but no https
        root * /home/ubuntu/public  ==> I want to use this one but not working

        # Enable the static file server.
        file_server

        # Another common task is to set up a reverse proxy:
        # reverse_proxy localhost:8080

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

2. Error messages and/or full log output:

I got the 403 error

3. Caddy version:

version is 2.6.4

4. How I installed and ran Caddy:

I follow the official install process.

a. System environment:

Linux Ubuntu 22.04

b. Command:

I use caddy reload in the etc/caddy/ folder after I edit the Caddyfile follow blow.

c. Service/unit/compose file:

I didn’t use this.

d. My complete Caddy config:

:80 {
        # Set this path to your site's directory.
        # root * /usr/share/caddy  ==> default 
        # root * /usr/share/pubic   ==> this one work but no https
        root * /home/ubuntu/public  ==> I want to use this one but not working

        # Enable the static file server.
        file_server

        # Another common task is to set up a reverse proxy:
        # reverse_proxy localhost:8080

        # Or serve a PHP site through php-fpm:
        # php_fastcgi localhost:9000
}

5. Links to relevant resources:

I search with caddy2, root, hugo keywords but didn’t found the solution.

The caddy user doesn’t have permission to read files from other users home directories.

Move your files to /srv or /var/www/html instead and serve them from there.

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