Tracking real visitors IP address in access log

lsqtwrk

Administrator
#22
the OLS should only have 2 rules

1. HTTPS redirection

2. proxy rule for Apache

in that order , the order of rules are also important


any other rules you should apply in apache's htaccess.
 
#23
Ok

I have one query in my mind now. Please help me to clear it.
In this case,

if I put cache rules in apache .htaccess , how OLS will given benefit of caching?

I read many places it will still give cache but how and is this correct ?
 

lsqtwrk

Administrator
#24
Ok

I have one query in my mind now. Please help me to clear it.
In this case,

if I put cache rules in apache .htaccess , how OLS will given benefit of caching?

I read many places it will still give cache but how and is this correct ?
Ohhhhh, sorry I was mistaken.

Rewrite rule in Apache htaccess may not work, it will require HTTP header to tell OLS what to cache.

I only tested with WordPress on Apache + OLS, which the LSCWP plugin will send the HTTP header OLS needed. But didn't test other

Let me do some test and get back to you
 

lsqtwrk

Administrator
#26
Hi,

OK , just tested

you will have to it in one of the following 2 ways

1. use PHP header function , e.g.

header('x-litespeed-cache: public, max-age=120');

to tell OLS to cache it.

2. use rewrite rule in OLS rewrite tab

so your rule will be like


HTTPS redirection rule

LiteSpeed Cache rule

Proxy to Apache rule


in that order.
 

lsqtwrk

Administrator
#28
Code:
RewriteCond %{HTTPS} !=on

RewriteRule (.*) https://DOMAINNAME/$1[R=301,L]
#for https


RewriteCond %{REQUEST_URI} !admin
RewriteRule .* [E=Cache-Control: public, max-age=120]
#if URL does not contain admin , then cache it for 120 seconds


RewriteRule ^.(*)$ http://apachehttps/$1 [P,L]
# if not cached, proxy it to apache
it should be like this.

but I feel use PHP header will be more flexible
 
#30
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

I added CloudFront before this setup and now apache logs showing only CloudFront IP only not actual visitors IP. Any more changes to track real visitor if CDN is active?
 

lsqtwrk

Administrator
#31
I added CloudFront before this setup and now apache logs showing only CloudFront IP only not actual visitors IP. Any more changes to track real visitor if CDN is active?
I don't know much about CloudFront , but if your previous , before-CloudFront , setting works , then you should probably need to check CloudFront setting if there is any setting that passes the client IP.
 
Top