Last active
October 11, 2019 01:54
-
-
Save AndisGrossteins/68469346adbc379f3ad74138e3ab6f5b to your computer and use it in GitHub Desktop.
A hack to log real IP addresses on share Apache hosting behind CloudFlare (or other) reverse proxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set environment variables from request headers and add them to User-Agent header | |
# it's not much but it works | |
# Requirements: | |
# 1 - mod_setenvif (http://httpd.apache.org/docs/current/mod/mod_setenvif.html) | |
# 2 - mod_headers (http://httpd.apache.org/docs/current/mod/mod_headers.html) | |
<IfModule mod_setenvif.c> | |
# Add envirinment variables from a request header | |
SetEnvIf CF-Connecting-IP "^(.+)$" CF_Connecting_IP=$1 | |
</IfModule> | |
<IfModule mod_headers.c> | |
# This adds the variable only if it exists | |
RequestHeader append "User-Agent" "CFIP=%{CF_Connecting_IP}e" env=CF_Connecting_IP | |
RequestHeader append "User-Agent" "XFF=%{HTTP_X_FORWARDED_FOR}e" env=HTTP_X_FORWARDED_FOR | |
</IfModule> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment