Tracking real visitors IP address in access log

#1
Hi,

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

127.0.0.1 - - [11/Jan/2020:19:23:27 +0530] "GET /category/pizza HTTP/1.1" 200 93484
127.0.0.1 - - [11/Jan/2020:19:23:28 +0530] "GET /cdn/recipes/marwaelmanawy-i-cheef-recipe-19.jpg HTTP/1.1" 200 28872
127.0.0.1 - - [11/Jan/2020:19:23:29 +0530] "GET /category/ice-cream2 HTTP/1.1" 200 57692
127.0.0.1 - - [11/Jan/2020:19:23:31 +0530] "GET /category/bread HTTP/1.1" 200 57660
127.0.0.1 - - [11/Jan/2020:19:23:33 +0530] "GET / HTTP/1.1" 200 127274
 
#3
Thank you for response but its not working. Still I am able to see local IP on apache access log for that domain.

127.0.0.1 - - [13/Jan/2020:20:02:52 +0530] "GET /recipes HTTP/1.1" 200 103233
127.0.0.1 - - [13/Jan/2020:20:02:56 +0530] "GET /category/kids HTTP/1.1" 200 66504
127.0.0.1 - - [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?
 

lsqtwrk

Administrator
#9
It works on my installation

ScreenShot2020-01-1317.05.47_meitu_1.jpg

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.
 

lsqtwrk

Administrator
#13
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.
 

lsqtwrk

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

I also found the solution

my conf:

Code:
SetEnvIf REMOTE_ADDR "(.+)" CLIENTIP=$1
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
 
#16
@lsqtwrk
In this type of setup, How to get the benefit of the cache at OLS level.

I checked URL https://openlitespeed.org/kb/litespeed-cache-on-openlitespeed-without-plugins/
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?
 
Top