Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Apache XForwardedFor Header

Apache XForwardedFor Header

Apache XForwardedFor Header

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!!

# 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

# JkRequestLogFormat set the request format
JkRequestLogFormat "%w %V %T"

RE: Apache XForwardedFor Header

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close