caddyserver / website

The Caddy website
154 stars 150 forks source link

Following the docs leads to service failure #420

Open ahoiroman opened 3 days ago

ahoiroman commented 3 days ago

The docs at https://caddyserver.com/docs/caddyfile/options#admin describe how to use a unix socket in order to make the api listen to the unix socket.

{
    admin unix//run/caddy-admin.sock
}

Following this leads to a service failure on restart:

Oct 01 06:07:00 server1 caddy[56725]: Error: loading initial config: loading new config: starting caddy administration endpoint: permission denied

This happens, if caddy is installed via package manager and running as user caddy.

But even if I create that socket using:

touch /run/caddy-admin.sock
chown caddy: /run/caddy-admin.sock
chmod 0600 /run/caddy-admin.sock

Leads to the very same error:

Oct 01 06:10:14 server1 caddy[56747]: Error: loading initial config: loading new config: starting caddy administration endpoint: permission denied

mohammed90 commented 3 days ago

As mentioned on the forum, this is due to how systemd works. Users are generally expected to know better how their system is setup and which directories should the service be allowed to access. It's not related to the file's absence/presence or the file permissions. The only thing we can do in terms of documentation is to mention that users should be mindful of their system setup and perhaps need to adjust their init system, but we cannot assume all users use systemd-led Linux distro. Other *nix systems might not have the same restrictions enforced by systemd.

ahoiroman commented 3 days ago

My issue was in fact pointing in that direction: Adding more context to the docs.

I think I am working that out and, if it's something you'd welcome, I'll create a PR for the docs.

mohammed90 commented 3 days ago

PRs are always welcome and appreciated! Documentation written from user's perspective may be clearer than ones written by the developers and maintainers.