-
-
Notifications
You must be signed in to change notification settings - Fork 94
Improve X-Forwarded-For handling #495
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
Changed Files
|
4cfa569
to
27a0772
Compare
It looks fine to me. You need to add some log examples in the PR description of your tests and update the documentation page, you can find the doc page here and check out this if you want to build the docs locally. Let me know when the PR is ready to review it. -- Additionally, I wonder if we also need to support a trust all proxies option for reverse proxies with non-static IPs like AWS ELB or similar. |
27a0772
to
0c08c4a
Compare
Yeah i took some time to think it over and to me it seemed the most sensible thing was to seperate the x-forwarded-for logging from the remote address logging completely. I have introduced two new options, one to toggle logging of the x-forwarded-for header and one to optionally allowlist certain IPs, where the default is to trust all IPs. I also ran into some issues when trying to build the docs, the command here doesn't seem to mount the docs in the correct directory. I also found some other small issues with the documentation, i will open a seperate issue for this. |
The docs instructions are kind of outdated but feel free to update them. For running the Docs dev server via Docker, just try |
0c08c4a
to
e31aa52
Compare
This is ready to be reviewed btw. Sorry i forgot to mention that. |
Great, I will give it a check today. |
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.
It looks fine to me.
I just left an update on the logging feature page to do. After that, we should merge the PR.
ce690b2
to
c916540
Compare
Adds a `log-forwarded-for` option to control if the X-Forwarded-For header information should be logged. Also includes a `trusted-proxies` option to optionally specify from which IPs to accept this header. Existing uses of log-remote-address will stop logging forwarded-for IPs after this change.
c916540
to
af6dbb6
Compare
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.
Ready for the next release, Thanks!
Description
Adds two new options to configure logging of X-Forwarded-IP addresses.
log-forward-for
: is a boolean to enable logging of the header in the first place. Logging is done in the same manner as log-remote-address, meaning it will only show with log-level info or highertrusted-proxies
: is an optional list of IP addresses from which to accept the x-forwarded-for header. If unspecified or an empty string, all IP addresses are allowedBoth of the options are optional and log-forward-for defaults to false. This means that existing uses of log_remote_address will silently stop logging from the x-forwarded-for header.
Related Issue
Resolves #494
Motivation and Context
See #494
How Has This Been Tested?
I have tested all combinations of
log-remote-addr
,log-forwarded-for
andtrusted-proxies
with both CLI options and a config file. I confirmed that they output the expected logs.Screenshots (if appropriate):
Some config snippets and what they output. The requests are all sent from
::1
withX-Forwarded-For: 1.1.1.1
Example 1:
Example 2 (this would reflect the old behavior):
Example 3:
Example 4: