Is it possible for caddy to block URLs containing certain words ? As these certain words change all the time, is it also possible to achieve this dynamicly, say reading a text file that the words are kept ?
Because otherwise i have to alter the Caddyfile and restart the caddy every time.
Simply if the URL contains a word from a local text file block it.
This is exactly the kind of situation where you should write your own plugin for Caddy:
You can write a custom HTTP request handler which reads and caches those filtering rules, and applies them to each request.
I wish i had known Go language.:)Thanks though.
Trust me, it’s easier than you think. Give it a shot! The guide walks you through it quite well. You could probably do what you need in like ~100 lines of code or less.
Mobile right now, but couldn’t you match on the existence of substrings in the url?
That’s what i’m tryin to achieve but substrings in the url change all the time so the will-be-matched words too.
I can keep the words in a text file and alter it dynamicly when needed. That’s why i’m looking for a way to achieve it automaticly without altering the caddyfile and restart caddy every time.
FYI you should not “restart” Caddy when you change the config, you should “reload” it, which is a zero-downtime config change.
But still, writing a plugin is definitely the solution you need. Just try! Go is an easy language to learn, especially with VSCode Go extension linter and on-save auto-code-fixing.
What’s wrong with posting the new config to Caddy though? That’ll be more efficient than reading a file. Caddy reloads are very lightweight.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.