Is it possible to automatically apply the tls command to every domain in my Caddyfile?

1. Caddy version:

v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I installed, and run Caddy:

$ sudo apt install caddy

a. System environment:

Debian 11 (systemd, of course). I’m using Caddy as a reverse proxy for a handful of Docker containers, but Caddy is NOT running in Docker.

b. Command:

N/A - I manage it through systemd (sudo systemctl restart caddy to restart it)

c. Service/unit/compose file:


d. My complete Caddy config: {
        tls /certs/ /certs/
        reverse_proxy :8002
} {
        tls /certs/ /certs/
        reverse_proxy :8001
} {
        tls /certs/ /certs/
        reverse_proxy :8086
} {
        tls /certs/ /certs/
        reverse_proxy :8003

The exact domain I’m using isn’t relevant (and these services are internal). I have a custom certificate partially due to that

3. The problem I’m having:

Writing tls /certs/ /certs/ for each domain is annoying. Is it possible to write it once and somehow have it apply to every domain automatically?

4. Error messages and/or full log output:

N/A - I’m just wondering how to do it

5. What I already tried:

I’ve tried removing it from each domain and putting tls /certs/ /certs/ at the very start of the file. I’ve also tried having it at the start, but with curly braces around it. Neither of those worked.

6. Links to relevant resources:



Snippets allow you to configure a snippet once and then import it into any site block by doing import name-of-snippet


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