No idea why you’re seeing such weird behaviour, but here’s a quick example from my laptop.
But let me say this first: unless you really need to, do NOT expose the admin API to anything beyond localhost. It’s locked down by default for a reason.
Step 1: test to see if the site is alive
example.com {
tls internal
respond "Alive!"
}
$ curl https://example.com/config/
Alive!
Step 2: proxy the site to the admin API
example.com {
tls internal
reverse_proxy localhost:2019
}
$ curl https://example.com/config/
{"error":"host not allowed: example.com"}
Step 3: try again to proxy the site to the admin API
at this point, I really hope you know what you’re doing

{
admin localhost:2019 {
origins example.com
}
}
example.com {
tls internal
reverse_proxy localhost:2019
}
$ curl https://example.com/config/
{"admin":{"listen":"localhost:2019","origins":["example.com"]},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:2019"}]}]}]}],"match":[{"host":["example.com"]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"issuers":[{"module":"internal"}],"subjects":["example.com"]}]}}}}
Step 4: add some basic authentication
{
admin localhost:2019 {
origins example.com
}
}
example.com {
tls internal
basic_auth {
admin $2a$14$A410L2y9j/gOYY58Husn6.2e2eOR8W/wjM5zfXcgXENrKFMLDHjDi
}
reverse_proxy localhost:2019
}
$ curl https://example.com/config/ -i
HTTP/2 401
alt-svc: h3=":443"; ma=2592000
server: Caddy
www-authenticate: Basic realm="restricted"
content-length: 0
date: Wed, 05 Nov 2025 01:00:50 GMT
$ curl https://example.com/config/ -u admin:REDACTED
{"admin":{"listen":"localhost:2019","origins":["example.com"]},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"authentication","providers":{"http_basic":{"accounts":[{"password":"$2a$14$A410L2y9j/gOYY58Husn6.2e2eOR8W/wjM5zfXcgXENrKFMLDHjDi","username":"admin"}],"hash":{"algorithm":"bcrypt"},"hash_cache":{}}}},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:2019"}]}]}]}],"match":[{"host":["example.com"]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"issuers":[{"module":"internal"}],"subjects":["example.com"]}]}}}}
Step 5: enforce origin
{
admin localhost:2019 {
origins example.com
enforce_origin
}
}
example.com {
tls internal
basic_auth {
admin $2a$14$A410L2y9j/gOYY58Husn6.2e2eOR8W/wjM5zfXcgXENrKFMLDHjDi
}
reverse_proxy localhost:2019
}
$ curl https://example.com/config/ -u admin:REDACTED
{"error":"client is not allowed to access from origin ''"}
$ curl https://example.com/config/ -u admin:REDACTED -H 'Origin: https://example.com'
{"admin":{"enforce_origin":true,"listen":"localhost:2019","origins":["example.com"]},"apps":{"http":{"servers":{"srv0":{"listen":[":443"],"routes":[{"handle":[{"handler":"subroute","routes":[{"handle":[{"handler":"authentication","providers":{"http_basic":{"accounts":[{"password":"$2a$14$A410L2y9j/gOYY58Husn6.2e2eOR8W/wjM5zfXcgXENrKFMLDHjDi","username":"admin"}],"hash":{"algorithm":"bcrypt"},"hash_cache":{}}}},{"handler":"reverse_proxy","upstreams":[{"dial":"localhost:2019"}]}]}]}],"match":[{"host":["example.com"]}],"terminal":true}]}}},"tls":{"automation":{"policies":[{"issuers":[{"module":"internal"}],"subjects":["example.com"]}]}}}}