Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set custom global variables in Caddyfile

Tags:

caddy

I have multiple reverse_proxy entries that share the same destination host. Isn't there a way to set a global variable inside the Caddyfile in order to reuse it?

app1.dns {
    reverse_proxy myhost:xxxx
}

app2.dns {
    reverse_proxy myhost:yyyy
}

app3.dns {
    reverse_proxy myhost:zzzz
}
like image 437
anat0lius Avatar asked Oct 15 '25 06:10

anat0lius


1 Answers

Caddy Snippets

The re-usable global configuration is possible to define once use anywhere within caddyfile, example here

(snippet) {
  respond "Yahaha! You found {args.0}!"
}

(hello) {
  respond "Hello {args.0}!"
}

a.example.com {
  import snippet "Example A"
}

b.example.com {
  import hello "World"
}
like image 156
Jinna Balu Avatar answered Oct 18 '25 23:10

Jinna Balu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!