Caddyfile Inheritance for Site Settings

So let’s say that I have this bit of config that I want to import into all of my websites.

(block-wordpress) {
	@wordpress {
		path_regexp wp-\w+
	}
	respond @wordpress "No Wordpress here. Piss Off!!!" 404
}

Right now I can do this…

website.com {
	root * /var/ww/website.com
	import block-wordpress
}
website2.com {
	root * /var/ww/website2.com
	import block-wordpress
}

Now in real life I have a lot more config than that so it would be nice if I could centralize the common imports/config that can go into all sites. Maybe something like this…?

* {
	import block-wordpress
}
website.com {
	root * /var/ww/website.com
}
website2.com {
	root * /var/ww/website2.com
}

No, there’s no implicit configuration. You need to explicitly import snippets into each site.

This is an intentional design decision. If we did allow implicit configuration, then other users would then ask “how do I override the implicit configuration I added?” And the answer would have to be “just don’t use implicit configuration, then.” It’s a hard problem with no good solution. It would add a lot of complexity that isn’t worth having.

1 Like

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