Skip to content

Conversation

fabien-chebel
Copy link

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.

# 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`.
@rainerjung
Copy link
Contributor

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
Copy link
Contributor

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

@markt-asf
Copy link
Contributor

This PR should use NetMaskSet as well.

@aooohan
Copy link
Member

aooohan commented Oct 26, 2023

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

@ABin-Huang
Copy link

@aooohan @markt-asf Can you reassign this question to me,I want to try to solve it

@markt-asf
Copy link
Contributor

No need to assign it, you can just start work. You probably want to create a new PR. If you do, and if it looks more promising than this one, this one will be closed.

ABin-Huang added a commit to ABin-Huang/tomcat that referenced this pull request Sep 7, 2025
ABin-Huang added a commit to ABin-Huang/tomcat that referenced this pull request Sep 12, 2025
@ABin-Huang
Copy link

No need to assign it, you can just start work. You probably want to create a new PR. If you do, and if it looks more promising than this one, this one will be closed.

@markt-asf hi,The code has been pushed for review. Please let me know if there are any further adjustments needed, such as optimizing error handling or supplementing documentation. thanks

@markt-asf
Copy link
Contributor

Please create a PR for your proposed solution.

@ABin-Huang
Copy link

oh Sorry, I forgot. Now has been created. Please check.

@markt-asf
Copy link
Contributor

Closing in favour of #894

@markt-asf markt-asf closed this Sep 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants