Internal/external acme+dns setup

You’ll likely need to reload like this instead:

curl -X POST "http://localhost:2019/load" \
	-H "Content-Type: text/caddyfile" \
	-H "Origin: whatever" \
	--data-binary @/etc/caddy/Caddyfile

But I don’t think what you’re trying to do makes sense (see below).

Those are two separate concepts altogether. One is for the admin API, and the other is for your actual sites you’re serving.

There’s no existing plans for augmenting the enforce_origins feature, but Caddy v2.4.0 will introduce new features to admin that may be what you’re hoping for:

What are you looking to do with the API though? Because generally it’s either-or on Caddyfile vs JSON+API. Since Caddyfile to JSON is one-way, any time you make config changes via the JSON API, those changes will be lost the next time you reload from the Caddyfile.

(Although Caddy does persist an autosave.json which can be paired with the --resume option to make Caddy load from that on initial startup instead – you should probably use the caddy-api service instead of caddy if you’re going that route.)

So either go all-in on JSON, (and you may use the Caddyfile adapter to as a basis for your initial JSON config), or go all-in on the Caddyfile and limit yourself to the functionality it provides.