Tracking real visitors IP address in access log


I am using OLS as a proxy for speed and security. Today we noted that no real IP gets logged in access log or error.

How to log actual IP for the visitor ? Apache logs showing - - [11/Jan/2020:19:23:27 +0530] "GET /category/pizza HTTP/1.1" 200 93484 - - [11/Jan/2020:19:23:28 +0530] "GET /cdn/recipes/marwaelmanawy-i-cheef-recipe-19.jpg HTTP/1.1" 200 28872 - - [11/Jan/2020:19:23:29 +0530] "GET /category/ice-cream2 HTTP/1.1" 200 57692 - - [11/Jan/2020:19:23:31 +0530] "GET /category/bread HTTP/1.1" 200 57660 - - [11/Jan/2020:19:23:33 +0530] "GET / HTTP/1.1" 200 127274
Thank you for response but its not working. Still I am able to see local IP on apache access log for that domain. - - [13/Jan/2020:20:02:52 +0530] "GET /recipes HTTP/1.1" 200 103233 - - [13/Jan/2020:20:02:56 +0530] "GET /category/kids HTTP/1.1" 200 66504 - - [13/Jan/2020:20:02:56 +0530] "GET /cdn/users/4.jpg HTTP/1.1" 200 32626

restart services but no luck. Any change in proxy redirection?


It works on my installation


the 88. IP are my browser , first 3 tests without OLS installed and configured

51. IP is shown when I configured OLS for reverse proxy , that is also the server IP

then the last one , once I enabled Use Client IP in Header to Yes, it records my browser IP again instead of server IP.


hmmm , I checked the configuration , but didn't see anything special rather than the one I posted before.

I will run test again with different Apache setup.


I tried with other Apache installation , this time I did encounter the issue..

I also found the solution

my conf:

SetEnvIf X-Forwarded-For "^([0-9.]+)" CLIENTIP=$1
LogFormat "%{CLIENTIP}e %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" CLIENTIP
CustomLog  /path/to/access.log CLIENTIP
In this type of setup, How to get the benefit of the cache at OLS level.

I checked URL
Where we can use Rules but where to write that rules?

In my setup ( OLS + Apache ), now .htaccess is belongs to apache.

Is any setting which works for all type of application hosted on OLS especially for cache benefit.

I have added rewrite rule on OLS to send all traffic to apache using

RewriteCond %{HTTPS} !=on
RewriteRule (.*) https://DOMAINNAME/$1 [R=301,L]
REWRITERULE ^(.*)$ HTTP://apachehttps/$1 [P,L]

Can I add cache code here too so that apache hosted application get 100% benefit from OLS cache? If yes, What to add?