-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add support for Forwarded-For and Real-IP headers in HTTP inputs #22872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
add hashcode/equals to resolvable inet socket address wrapper, comparing them in tests add RawMessageHandler test fix subnet trusted proxy code (yay tests)
bernd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed two issues during testing that need to be addressed before I can continue testing and review.
graylog2-server/src/main/java/org/graylog2/inputs/transports/netty/HttpForwardedForHandler.java
Outdated
Show resolved
Hide resolved
graylog2-server/src/main/java/org/graylog2/inputs/transports/netty/HttpForwardedForHandler.java
Outdated
Show resolved
Hide resolved
…ke it clear FullHttpMessage objects need to be retained, because they contain the body as well (the reason we switched the type) guard against invalid ip literals and log a warning in case we cannot parse the ip address debug log if we don't know any relaying proxy
…roxies don't include themselves in the forwarded-for list
bernd
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I tested this change with different setting configurations.
/prd https://github.com/Graylog2/graylog-plugin-enterprise/pull/11072
Description
This change adds a netty channel handler that extracts the original IP from various headers if configured appropriately.
The default settings behave as before, users can enable handling
X-Forwarded-For/Forwardedheaders, optionally enforcing all proxy IPs to be in thetrusted_proxiessetting, as well as taking the client's IP from aX-Real-IP(or similar style) header.When checking against
trust_proxiesGraylog will also consider the remote address of the HTTP socket to be a proxy and check its address. Some proxies do not include themselves, e.g. traefik does this, so Graylog considers the remote side to be a proxy in this case as well.Motivation and Context
If Graylog runs behind a load balancer or proxy and the codec or processing doesn't explicitly set the message
source, Graylog will use the remote address of the HTTP network connection, which ends up being the proxy's address, not the client's IP.This change allows overriding the IP, based on standard headers, or de-facto industry conventions.
How Has This Been Tested?
Added unit tests.
Types of changes
Checklist:
Fixes #22837