FREE THOUGHT · FREE SOFTWARE · FREE WORLD

Home » Hosting » Apache Logging for Remote Addresses using X-Forwarded-For

by comment

SetEnvIf ^X-Forwarded-For$ ^$ noxforward
SetEnvIf Remote_Addr "(.+)" xremote=$1
RequestHeader set X-Forwarded-For %{xremote}e env=noxforward

LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%v %{X-FORWARDED-FOR}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" commonvhost
Contents [hide]

LOG Formats and Settings

#  LOG Formats and Settings {{{2
# ================================================================================
SetEnvIf ^X-Forwarded-For$ ^$ noxforward
SetEnvIf ^X-Forwarded-For$ "(.+)" xforwarded=$1

SetEnvIf ^X-Cluster-Client-Ip$ ^$ noxclusterip
SetEnvIf ^X-Cluster-Client-Ip$ "(.+)" xclusterip=$1

SetEnvIf Remote_Addr ^$ noxremote
SetEnvIf Remote_Addr "(10\.183\.253\.48)" noxremote
SetEnvIf Remote_Addr "(.+)" xremote=$1

#  If the environment variable specified in the env=... argument exists (or if the environment variable does not exist and env=!... is specified) then the action specified by the RequestHeader directive will take effect.
RequestHeader set X-ISC-IP %{xclusterip}e env=!noxclusterip
RequestHeader set X-ISC-IP %{xclusterip}e env=!noxremote
RequestHeader set X-ISC-IP %{xremote}e env=!xclusterip

LogFormat "%v %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%v %{X-ISC-IP}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" commonvhost

Tags

Comments Welcome

Information is freedom. Freedom is non-negotiable. So please feel free to modify, copy, republish, sell, or use anything on this site in any way at any time ;)

My Online Tools

Popular Articles
Hacking and Hackers

The use of "hacker" to mean "security breaker" is a confusion on the part of the mass media. We hackers refuse to recognize that meaning, and continue using the word to mean someone who loves to program, someone who enjoys playful cleverness, or the combination of the two.
-- Richard M. Stallman


It's very simple - you read the protocol and write the code. -Bill Joy

Except where otherwise noted, content on this site is licensed under a Creative Commons Attribution 3.0 License, just credit with a link.
This site is not supported or endorsed by The Apache Software Foundation (ASF). All software and documentation produced by The ASF is licensed. "Apache" is a trademark of The ASF. NCSA HTTPd.
UNIX ® is a registered Trademark of The Open Group. POSIX ® is a registered Trademark of The IEEE.

+Askapache | htaccess.io | htaccess.guru

Site Map | Contact Webmaster | License and Disclaimer | Terms of Service | @Htaccess

↑ TOPMain