Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
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.
| |
|
Topic: Real Client IP in Apache access logs |
|
Author |
|
Divya
Joined: 12 Jan 2016 Posts: 4 Location: USA
|
Posted: Tue 12 Jan '16 17:44 Post subject: Real Client IP in Apache access logs |
|
|
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
|
Posted: Wed 13 Jan '16 13:28 Post subject: |
|
|
Are you behind a proxy or why you use X-Forwarded-For ? |
|
Back to top |
|
Divya
Joined: 12 Jan 2016 Posts: 4 Location: USA
|
Posted: Wed 13 Jan '16 14:56 Post subject: |
|
|
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
|
Posted: Wed 13 Jan '16 17:52 Post subject: |
|
|
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 |
|
|
|
|
|
|