How do I dynamically block the request ip address by request path?

1. The problem I’m having:

How do I dynamically block the request ip address by request path?

example.com {
	handle /wp-login.php {
                # append {http.request.remote} to black list and apply immediately
        }
}

If this cannot be done with Caddyfile, does caddy provide any related api related to black list management? So I can forward {http.request.remote} to a backend then perform the caddy api.

2. Error messages and/or full log output:

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

apt

a. System environment:

Ubuntu 20.04.6 LTS x86_64

b. Command:

nano Caddyfile

Caddy doesn’t have anything like that built-in, but there might be some third-party plugins that could help you with that. I don’t use any of them though so I can’t vouch for them.

Some people use tools like fail2ban to block the connections at the networking layer before it reaches Caddy, that’s more efficient than Caddy itself blocking connections.

1 Like

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