Skip to content
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

Support for extracting outermost client from X-Forwarded-For #11

Closed
wants to merge 2 commits into from

Conversation

christopherraa
Copy link

These two commits add support for using %x in the log format to extract the outermost client as set in the X-Forwarded-For header. This is useful in situations where you have multiple proxy-layers and perhaps already log the header with %{X-Forwarded-For}i but would like to have the convenience of logging the client ip in a separate field, for example instead of using %h.

I have tried to follow conventions already present in the code of this module, but feel free to point out any discrepancies or things that would need correcting for this pull-request to be accepted.

This commit adds naïve support for extracting the real client from
the X-Forwarded-For header as set by various cache and proxy services.
This implementation does not enforce or require that upstream has set
X-Forwarded-For correctly, but merely splits on `, ` and is able to
interpolate %x in the logging format to the outermost clients ip.
@christopherraa
Copy link
Author

By the way, %x (lowercase X) was chosen beause I believe that does not conflict with the existing fields in the Apache log format.

@augensalat
Copy link
Owner

As the documentation says this plugin mimics Apache mod_log_config format strings.
There is no %x there so I will not add it here at the risk of introducing potential incompatibilies with future versions of Apache's mod_log_config.
I also do not see real value in %x over specifiying "%{X-Forwarded-For}i" in the format.

@augensalat augensalat closed this Sep 4, 2016
@christopherraa
Copy link
Author

Ok. Thats fine. Just to clarify; the patch is meant to provide convenience so that information is made more easily available about the real client accessing the application. Instead of having to do extraction of that data through a separate step when processing log-data, or while looking at / grepping through the data manually.

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.

None yet

2 participants