How can I block a ip address with some configuration on web.xml?
Do I need a filter? How can I implement one?
A website may be IP blacklisted if its content is deemed inappropriate. This could be pornographic material, black market trade, or sensitive subjects such as weapons and arms deals. Internet Service Providers or even government agencies could actively block websites such as these and prevent users from accessing them.
In the Cloudflare dashboard, navigate to Firewall > Tools. Cloudflare tools dashboard. To create a new IP access rule, add an IP address, select the “Block” action, select “This Website” (or “All Websites in Account” if you want the rule to apply across all your Cloudflare domains), and click “Add”.
You can't do this purely through config in web.xml
, no. A servlet filter would be a good place to implement such a thing, though.
The Filter
interface supplies the HttpServletRequest
as part of the filter chain invocation, and from that you can get the IP address of the client (using getRemoteAddr
), and compare that to your list of permitted addresses.
Alternatively, your specific appserver might support IP filtering at a proprietary level, but that locks you into that container (which may or may not be a problem for you).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With