tomcat icon indicating copy to clipboard operation
tomcat copied to clipboard

Add support for CIDR notation in `RemoteIpFilter`

Open fabien-chebel opened this issue 2 years ago • 4 comments

Context

Tomcat's RemoteIpFilter currently allows configuring trusted/internal proxies using regexp.

When integrating with reverse proxies with a large number of IP addresses, regexp configuration gets cumbersome.

Suggestion

I suggest adding support for IP ranges in CIDR notation to make it easier to setup the filter in these cases.

For backward compatibility, matching with masks is only performed when the trusted/internal proxies patterns are null.

Depending on the feedback I receive on this PR, I may add the same changes to Tomcat's RemoteIpValve.

fabien-chebel avatar Jul 04 '23 19:07 fabien-chebel

I have not looked at your implementation suggestion, but did you notice there is:

https://tomcat.apache.org/tomcat-9.0-doc/config/filter.html#Remote_CIDR_Filter

rainerjung avatar Jul 04 '23 23:07 rainerjung

Ah, sorry I just realized what you plan. Please ignore my reference to RemoteCIDRFilter.

rainerjung avatar Jul 04 '23 23:07 rainerjung

This PR should use NetMaskSet as well.

markt-asf avatar Aug 02 '23 14:08 markt-asf

Hi, If you want this PR to merge smoothly, please modify this change according to markt‘s comment.

aooohan avatar Oct 26 '23 02:10 aooohan