Good question, I need to expand the docs about this.
This is on Linux I guess?
The basic idea is that itās a network socket, so you donāt want untrusted code to have access to it. Generally this is not a problem in the first place because if your system is running malicious code, itās game over anyways. So we assume that your system is secure to begin with.
By default, Caddyās admin port is bound to localhost:2019
(the significance of that port number is the year this feature was developed). That covers the majority of problems already. This means that remote code canāt access the port. To further increase security, you can restrict requests to come only from designated hosts / origins, with origins
and enforce_origin
in your admin config:
This is primarily useful against browser-based attacks, as it causes the admin API to emit CORS headers which browsers honor. (But since most people donāt deploy servers on the same machines that use web browsers, this is seldom a concern anyway and itās why itās not enforced by default.) As a nice bonus, enabling this also mitigates DNS rebinding attacks.
Another option on Linux is to use unix sockets. Simply permission the socket file so that only the Caddy process and any clients can access it. Then you donāt need to have Caddy enforce permissions itself, the OS does it for you.
So thatās basic local access protections in a nutshell.
You mentioned that you want to have permissions for users, etc. You can enable the remote admin endpoint, which is a different socket because it uses TLS (mandatory):
Youāll use the access_control
property to specify permissions for specific public keys. Thatās how you can control what each user can do.
In order for the admin endpoint to function, however, the server needs an identity certificate for itself. As the docs mention, you can use the identity
property of the config to tell Caddy what its identity is so it can manage a certificate for itself. If your server isnāt being accessed with a public DNS name, then you should configure the issuers
to be an internal issuer or your own ACME CA if youāre rolling your own PKI.
I really intend to write a docs page about this now, but for a while I was thinking it should be reserved for sponsors because itās a very powerful and advanced feature.
Does that help?