V2: Disable admin endpoint via Caddyfile

1. My Caddy version (caddy -version):

v2.0.0-beta11

2. How I run Caddy:

a. System environment:

macOS High Sierra 10.13.6

b. Command:

sudo caddy run -config /usr/local/etc/Caddyfile -adapter caddyfile

c. Service/unit/compose file:

-

d. My complete Caddyfile:

{
  admin {
    disabled true
  }
}

localhost:80 {
  tls off
  respond 200 {
    body "It works!"
    close
  }
}

(This is a reduced test case of the actual Caddyfile I’m using.)

3. The problem I’m having:

I’m trying to disable the admin endpoint completely using the Caddyfile syntax.

It looks like the global admin Caddyfile option isn’t documented yet in the v2 docs. I was able to find out that it supports the listen address like so:

{
  admin :1234
}

…but all variants I have tested to disable the endpoint completely (admin off, admin false and the variant from my Caddyfile above) didn’t work.

4. Error messages and/or full log output:

Output of caddy adapt for the Caddyfile above:

{
	"admin": {
		"listen": "localhost:2019"
	},
	"apps": {
		"http": {
			"servers": {
				"srv0": {
					"listen": [
						":80"
					],
					"routes": [
						{
							"match": [
								{
									"host": [
										"localhost"
									]
								}
							],
							"handle": [
								{
									"handler": "subroute",
									"routes": [
										{
											"handle": [
												{
													"body": "It works!",
													"close": true,
													"handler": "static_response",
													"status_code": 200
												}
											]
										}
									]
								}
							]
						}
					]
				}
			}
		}
	}
}

Output of the run command:

2019/12/28 16:18:06.376	INFO	admin	admin endpoint started	{"address": "localhost:2019", "enforce_origin": false, "origins": ["localhost:2019"]}
2019/12/28 16:18:06.376	INFO	http	server is only listening on the HTTP port, so no automatic HTTPS will be applied to this server	{"server_name": "srv0", "http_port": 80}
2019/12/28 17:18:06 [INFO][cache:0xc000684e60] Started certificate maintenance routine
2019/12/28 16:18:06.378	INFO	tls	cleaned up storage units
2019/12/28 16:18:06.378	INFO	admin	Caddy 2 serving initial configuration

5. What I already tried:

See 3.

6. Links to relevant resources:

https://github.com/caddyserver/caddy/issues/2833

Welcome, and thanks for trying Caddy 2 while it’s still in beta!

There isn’t a way to do this with the Caddyfile, yet. We’ll be rounding out the Caddyfile as the last thing before the stable release (the Caddyfile is really just a layering on top of Caddy, so we have to get the core of it right first).

Thanks for your fast reply!

I see, that’s fine. I’ll be working with v2 anyway until then. As it’s just my local dev setup, it’s fine for me to work with the beta. I’ll let you know on GitHub if I find any bugs.

I really love the flexibility and at the same time simplicity of Caddy, especially of v2. Keep it up! :slight_smile:

2 Likes

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