logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Real Client IP in Apache access logs
Author
Divya



Joined: 12 Jan 2016
Posts: 4
Location: USA

PostPosted: Tue 12 Jan '16 17:44    Post subject: Real Client IP in Apache access logs Reply with quote

Hi,

We are using Apache 2.2 installed on Linux and I am trying to configure access logs to print real client IP and modified the LogFormat as follows but it doesn't seem to work.Help appreciated.


LogFormat "%{X-Forwarded-For}i %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined

Thanks.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 13 Jan '16 13:28    Post subject: Reply with quote

Are you behind a proxy or why you use X-Forwarded-For ?
Back to top
Divya



Joined: 12 Jan 2016
Posts: 4
Location: USA

PostPosted: Wed 13 Jan '16 14:56    Post subject: Reply with quote

Yes, we are behind a proxy. Want to trace the actual client IP for trouble shooting purposes.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7373
Location: Germany, Next to Hamburg

PostPosted: Wed 13 Jan '16 17:52    Post subject: Reply with quote

Hm a solution might be

Code:

LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" proxy
SetEnvIf X-Forwarded-For "^.*\..*\..*\..*" forwarded
CustomLog "logs/access_log" combined env=!forwarded
CustomLog "logs/access_log" proxy env=forwarded


found at http://www.techstacks.com/howto/log-client-ip-and-xforwardedfor-ip-in-apache.html

If the IP is still empty then you have to look into the proxy config since it might not forward the client's IP.
Back to top


Reply to topic   Topic: Real Client IP in Apache access logs View previous topic :: View next topic
Post new topic   Forum Index -> Apache