Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Apache XForwardedFor Header

Status
Not open for further replies.

Frank DBA

Technical User
May 4, 2017
1
US
Not an Apache expert, but unfortunately am becoming one..

I have 3 web servers sitting behind a load balancer(F5). When one of these web servers reaches out to another server, it is resolving the F5's IP, and not the web server itself.

From what I've gained from this article below, I need to add the XForwardedFor setting to the header, which is done on the LogFormat setting in the config file.

What's written in that forum makes sense, however I need help as there are multiple locations of this LogFormat setting. I have two files which each contain multiples of this setting. I think I may only have to modify httpd.conf file, but I'm not too familiar with Apache. Any help is appreciated. Thanks!!

httpd.conf
#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%h %l %u %t \"%r\" %>s %b" common

<IfModule logio_module>
# You need to enable mod_logio.c to use %I and %O
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
</IfModule>

httdp-DM.conf
# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T
 
Hi Frank. I'm not too hip on load balancing but I might be able to sort you out a little on the LogFormat directive. This directive tells apache what information you want included in a particular log. Apache and/or its virtual host each have two logs. By default they are access_log and error_log. The article you linked to was saying that you can tell apache to get the information from the header and put it into a log file. Then you can read the log to see what apache sees when it is accessed. I don't know how your load balancer is setup but so I'll speak in generic terms. When a request comes to your router on its public ip address, it forwards all http on port 80 to the internal ip assigned to accept that traffic. Apache will be listening at this address on port 80 and take the request. The first thing it does is read the header of the request. It tells apache where the request is coming from, which browser, what domain they are requesting among a slew of other information. The article was showing how the logs can be setup to show the XForwardedFor information.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top