<div dir="ltr"><div class="">
<div class=""><div class=""><div class=""><p>Hi,<br> <br>
We've compile varnish with geoip module in order to cache country
based hashes, so far varnish<-> apache structure is working fine
with geoip module and caching requests based on countries but when we
add another Nginx proxy layer in front of varnish i.e nginx ->
varnish - apache, the geoip module stop tracking Country hashes and
varnish shows following logs :</p>
<p>TxHeader b X-GeoIP: Unknown</p>
<p>nginx : port 80<br>Varnish : port 6081<br>Apache : port 7172</p>
<p>So far, nginx is forwarding client ips to varnish but it looks like
varnish sessionstart value in varnishlog still showing ip : 127.0.0.1
due to which it is unable to track client's country. Only if someone can
point me to right direction.</p>
<p>varnishlog :</p>
<p> 15 BackendOpen b default 127.0.0.1 45806 127.0.0.1 7172<br> 15 BackendXID b 1609403517<br> 15 TxRequest b GET<br> 15 TxURL b /video/5708047/jeena-jeena-video-song-badlapur-atif-aslam<br> 15 TxProtocol b HTTP/1.1<br> 15 TxHeader b Referer: <a href="http://beta2.domain.com/videos/" rel="nofollow">http://beta2.domain.com/videos/</a><br> 15 TxHeader b X-Real-IP: 39.49.89.134<br> 15 TxHeader b X-Forwarded-Host: <a href="http://beta2.domain.com">beta2.domain.com</a><br> 15 TxHeader b X-Forwarded-Server: <a href="http://beta2.domain.com">beta2.domain.com</a><br> 15 TxHeader b Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
15 TxHeader b User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36<br> 15 TxHeader b Accept-Language: en-GB,en-US;q=0.8,en;q=0.6<br> 15 TxHeader b X-Forwarded-For: 39.49.89.134, 127.0.0.1<br> 15 TxHeader b host: default<br> 15 TxHeader b X-GeoIP: Unknown<br> 15 TxHeader b X-Varnish: 1609403517<br> 15 TxHeader b Accept-Encoding: gzip<br> 15 RxProtocol b HTTP/1.1<br> 15 RxStatus b 200<br> 15 RxResponse b OK<br> 15 RxHeader b Date: Tue, 20 Jan 2015 18:26:06 GMT<br> 15 RxHeader b Server: Apache<br> 15 RxHeader b Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1; expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/<br> 15 RxHeader b Expires: Thu, 19 Nov 1981 08:52:00 GMT<br> 15 RxHeader b Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0<br> 15 RxHeader b Pragma: no-cache<br>
15 RxHeader b Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/<br> 15 RxHeader b Set-Cookie:
pageredir=http%3A%2F%<a href="http://2Fbeta2.domain.com">2Fbeta2.domain.com</a>%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/<br> 15 RxHeader b Connection: close<br> 15 RxHeader b Transfer-Encoding: chunked<br> 15 RxHeader b Content-Type: text/html; charset=utf-8<br> 15 Fetch_Body b 3(chunked) cls 0 mklen 1<br> 15 Length b 127024<br> 15 BackendClose b default<br> 12 SessionOpen c 127.0.0.1 51675 :6081<br> 12 ReqStart c 127.0.0.1 51675 1609403517<br> 12 RxRequest c GET<br> 12 RxURL c /video/5708047/jeena-jeena-video-song-badlapur-atif-aslam<br> 12 RxProtocol c HTTP/1.0<br> 12 RxHeader c Referer: <a href="http://beta2.domain.com/videos/" rel="nofollow">http://beta2.domain.com/videos/</a><br> 12 RxHeader c Host: <a href="http://beta2.domain.com">beta2.domain.com</a><br>
12 RxHeader c Cookie: __qca=P0-993092579-1421436407272;
__qca=P0-1309575897-1421485050924;
__utma=198843324.254214983.1421436407.1421439435.1421777481.2;
__utmb=198843324.5.10.1421777481; __utmc=198843324;
__utmz=198843324.1421439435.1.1.utmcsr=(direct)|utmccn=(direct)<br> 12 RxHeader c X-Real-IP: 39.49.89.134<br> 12 RxHeader c X-Forwarded-Host: <a href="http://beta2.domain.com">beta2.domain.com</a><br> 12 RxHeader c X-Forwarded-Server: <a href="http://beta2.domain.com">beta2.domain.com</a><br> 12 RxHeader c X-Forwarded-For: 39.49.89.134<br> 12 RxHeader c Connection: close<br> 12 RxHeader c Cache-Control: max-age=0<br> 12 RxHeader c Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8<br>
12 RxHeader c User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36<br> 12 RxHeader c Accept-Language: en-GB,en-US;q=0.8,en;q=0.6<br> 12 VCL_call c recv lookup<br> 12 VCL_call c hash<br> 12 Hash c /video/5708047/jeena-jeena-video-song-badlapur-atif-aslam<br> 12 Hash c default<br> 12 Hash c Unknown<br> 12 VCL_return c hash<br> 12 VCL_call c miss fetch<br> 12 Backend c 15 default default<br> 12 TTL c 1609403517 RFC 0 -1 -1 1421778367 0 1421778366 375007920 0<br> 12 VCL_call c fetch<br> 12 TTL c 1609403517 VCL 3600 -1 -1 1421778367 -0<br> 12 VCL_return c deliver<br> 12 ObjProtocol c HTTP/1.1<br> 12 ObjResponse c OK<br> 12 ObjHeader c Date: Tue, 20 Jan 2015 18:26:06 GMT<br> 12 ObjHeader c Server: Apache<br> 12 ObjHeader c Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1; expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/<br> 12 ObjHeader c Expires: Thu, 19 Nov 1981 08:52:00 GMT<br> 12 ObjHeader c Pragma: no-cache<br>
12 ObjHeader c Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/<br> 12 ObjHeader c Set-Cookie:
pageredir=http%3A%2F%<a href="http://2Fbeta2.domain.com">2Fbeta2.domain.com</a>%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/<br> 12 ObjHeader c Content-Type: text/html; charset=utf-8<br> 12 VCL_call c deliver deliver<br> 12 TxProtocol c HTTP/1.1<br> 12 TxStatus c 200<br> 12 TxResponse c OK<br> 12 TxHeader c Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1; expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/<br> 12 TxHeader c Expires: Thu, 19 Nov 1981 08:52:00 GMT<br> 12 TxHeader c Pragma: no-cache<br>
12 TxHeader c Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/<br> 12 TxHeader c Set-Cookie:
pageredir=http%3A%2F%<a href="http://2Fbeta2.domain.com">2Fbeta2.domain.com</a>%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/<br> 12 TxHeader c Content-Type: text/html; charset=utf-8<br> 12 TxHeader c Content-Length: 127024<br> 12 TxHeader c Accept-Ranges: bytes<br> 12 TxHeader c Date: Tue, 20 Jan 2015 18:26:06 GMT<br> 12 TxHeader c Age: 0<br> 12 TxHeader c Connection: close<br> 12 Length c 127024<br> 12 ReqEnd c 1609403517 1421778366.722367764 1421778366.841626406 0.000178814 0.119145393 0.000113249<br> 12 SessionClose c Connection: close<br> 12 StatSess c 127.0.0.1 51675 0 1 1 0 0 1 602 127024<br> 0 CLI - Rd ping<br> 0 CLI - Wr 200 19 PONG 1421778367 1.0<br> 15 BackendOpen b default 127.0.0.1 45814 127.0.0.1 7172</p>
<p>Nginx proxy.inc :</p>
<p>proxy_redirect off;<br>proxy_hide_header Vary;<br>proxy_set_header Accept-Encoding '';<br>proxy_ignore_headers Cache-Control Expires;<br>proxy_set_header Referer $http_referer;<br>proxy_set_header Host $host;<br>proxy_set_header Cookie $http_cookie;<br>proxy_set_header X-Real-IP $remote_addr;<br>proxy_set_header X-Forwarded-Host $host;<br>proxy_set_header X-Forwarded-Server $host;<br>proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;</p>
<p>As you can see from proxy.inc file that nginx is forwarding client's
real ip to varnish but still varnish is unable to track client's GeoIP. Maybe i am missing some nginx settings because varnish:80 <-> apache:7172 structure working fine but nginx -> varnish is not.<br></p><p>Regards.<br>Shahzaib</p>
</div></div></div> </div></div>