[V2] global `tls` entry?

1. Caddy version (caddy version):

the docker image i am using

2. How I run Caddy:


a. System environment:


b. Command:

c. Service/unit/compose file:

Same as b

d. My complete Caddyfile or JSON config:

www.example.com, example.com {
        tls /opt/caddy/certs/cert.pem /opt/caddy/certs/key.pem

        respond "Hello there! sorry the site has been down so long, the motherboard died so i had to get a new server mobo"

3. The problem I’m having:

None, just got my server back up, redoing everything, and i was curious if it’s possible to have the tls directive globally set so I don’t have to add it to every single site config

4. Error messages and/or full log output:

Not Related

5. What I already tried:

No clue what to try, asking here

6. Links to relevant resources:

None that I know of, will update if any are given/found


Basically, I want to be able to have the config file that caddy is pointed at, contain this and only this

tls /opt/caddy/cert.pem /opt/caddy/key.pem
import /opt/caddy/sites/*.conf

and then have the site configs in /opt/caddy/sites/hostname.conf

if i have to change run time variables, like a flag, or a env, i have no problem doing so, i am using cloudflare-strict-tls, so this is why i want it like this

No, but you can make use of snippets to help:

oh thats neat, does the whole import /opt/sites/*.conf thing work confirmed?

edit, global import works

Yeah, import works both from files and from snippets.

You can also pass arguments on import that you can reference using {args.N} placeholders:

neat, thanks man!

1 Like

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