Error - read-only file system - storage is probably misconfigured

1. The problem I’m having:

After installing CaddyServer on Ubuntu 22.04.4 LTS (GNU/Linux 6.5.0-1014-aws x86_64) add test the first certificate I’m keep getting error.

2. Error messages and/or full log output:

{"level":"debug","ts":1711424877.244184,"logger":"http.stdlib","msg":"http: TLS handshake error from 185.149.254.53:60051: failed storage check: open /etc/caddy_data/rw_test_7465987084182321390: read-only file system - storage is probably misconfigured"}

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
sudo apt update
sudo apt install caddy

sudo mkdir /etc/caddy_data
sudo chmod -R 777 /etc/caddy_data
sudo chown -R caddy:caddy /etc/caddy_data

sudo systemctl reload caddy

a. System environment:

Ubuntu 22.04.4 LTS (GNU/Linux 6.5.0-1014-aws x86_64)

d. My complete Caddy config:

{
        debug
        storage file_system {
                root /etc/caddy_data
        }

        # TLS Options
        cert_issuer acme https://acme-v02.api.letsencrypt.org/directory

        email noam@example.com

        on_demand_tls {
                ask https://www.example.com/domain.php
        }

        # Disable redirect
        auto_https disable_redirects
}

:443 {
        tls {
                on_demand
        }
        #redir http://www.{host}{uri}
        respond "Welcome to the testing page! {host}"
}

:80 {
        #redir http://www.{host}{uri}
        respond "Welcome to the testing page! {host}"
}

Our standard systemd unit file ships with ProtectSystem=full. The ProtectSystem=full directive in the systemd unit file sets the entire filesystem as read-only except for selected directories. You need to add ReadWritePaths=/etc/caddy_data to the systemd unit file. Instructions on how to override the systemd unit file can be found here:

1 Like

Why are you trying to change the storage directory? Why not leave it as the default, i.e. /var/lib/caddy/.local/share/caddy ?

Although I understand it’s working like that, I just wanted to check the storage option and understand why it’s not working. This will help me avoid any surprises later on.