Blocking certain requests

So my website is working just fine, because Caddy is great as always :smiley:.

However, I can see that Iā€™m getting requests for routes like */.env

How do I straight up block / ban requests like this?

You can achieve this with a path matcher specifying the bad paths you want to block, and a respond directive paired with that matcher, perhaps with a status 403.

See:
https://caddyserver.com/docs/caddyfile/matchers#path
https://caddyserver.com/docs/caddyfile/directives/respond

1 Like

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