-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Log Format adjustment to log X-Forwarded-For (realip) #2678
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
Comments
Hello @Rdago , Just to note first that the value of X-Forwarded-For (like other request headers) is available in the audit log in section B. If you specifically want that output in the debug log, one way to do it would be to create a rule that triggers that output. Something like:
Keep in mind, however, that leaving the debug log turned on in a production environment tends to be very costly in terms of performance, and it can consume your disk space very quickly. The debug log is great for debugging and some experimentation, but it's unlikely to be an advisable solution for any ongoing production reporting. |
Hello @martinhsv thanks for your answer. I managed another way to do this because my setup is kindly different and more complex than usual. Is there a way I can log the unique ID on every created debug log? For Every Rule I´d like to log the Unique ID. Maybe you have a tip for me. |
Assuming you mean the unique_id that ordinarily appears in the audit log's part H as something like:
That unique id is available as the first line of each relevant line in the debug log. E.g.:
|
Yeah I`d like to see this in my debug.log like this:
but instead I get log messages like this:
|
The debug log is not really intended to duplicate the content of the audit log. Another way that you can output the unique_id explicitly is with the variable of that name: https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-%28v2.x%29#unique_id You could create a rule simply for the purpose of outputing that value (similar to the X-Forwarded-For rule I provided earlier). It is possible, though, that whatever is causing the unique id to not appear on the debug log lines might prevent this option from working too. Without knowing the reason it's hard to be sure. Note that if you aren't seeing the unique_id ever, that may imply that you do not have it loaded. With ModSecurity v2 with Apache, mod_unique_id.so must be loaded for that functionality to work. (Since your '[unique_id "REDACTED"]' citation implies that you are seeing the unique id in the audit log, that may not be the explanation, but it's something that you can check.) In any case, since we've dealt with the inquiry that began and entitled this issue, I'm going to go ahead and close this item. |
Regarding #2447 one comment told to adjust the apache2 error log in order to retrieve the X-Forwarded-For Header in Modsecurity logs. This is not possible in standalone version as there is no apache2 configuration available.
Is there any way to change the log behaviour of debug.log in Modsecurity standalone for example by adjusting the modsecurity.conf file?
What I´d like to have is a the possibility to log the ip address from the x-forwarded-for header in debug.log.
Thanks
The text was updated successfully, but these errors were encountered: