acheong08
(Antonio Cheong)
September 26, 2024, 9:47pm
1
1. The problem I’m having:
I want to use header_regexp to match user agents globally to block them
{
@go_http_client header User-Agent Go-http-client/1.1
handle @go_http_client {
abort
}
log {
output file /var/log/caddy/caddy.log
format json
exclude admin
}
}
(Yes, I know this is wrong. Just an example)
2. Error messages and/or full log output:
unrecognized global option: @go_http_client
3. Caddy version:
v2.8.4 h1:q3pe0wpBj1OcHFZ3n/1nl4V4bxBrYoSoab7rL9BMYNk=
a. System environment:
5.15.0-113-generic #123-Ubuntu SMP x86_64 GNU/Linux
5. Links to relevant resources:
Mohammed90
(Mohammed Al Sahaf)
September 26, 2024, 10:17pm
2
The global options section isn’t for applying handlers globally. It’s for specific configuration that are global to the process/server. See this page:
You can use snippets to define the recurring handling pattern, and then import it within the sites blocks.
1 Like
acheong08
(Antonio Cheong)
September 26, 2024, 10:28pm
3
Feels slightly redundant to copy/paste when there are a lot of sites but I suppose it might be time for me to just generate my Caddyfile from code. Thanks
I mean, snippets are scripted copy-paste for you. Just one import
line in each site.
1 Like
acheong08
(Antonio Cheong)
September 27, 2024, 12:31am
5
Yeah using that now. Still tedious when you have 100+ sites