Welcome! Log In Create A New Profile

Advanced

Geoip issue with nginx in front of varnish and apache !

January 20, 2015 01:40PM
Hi,

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 :

TxHeader b X-GeoIP: Unknown

nginx : port 80
Varnish : port 6081
Apache : port 7172

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.

varnishlog :

15 BackendOpen b default 127.0.0.1 45806 127.0.0.1 7172
15 BackendXID b 1609403517
15 TxRequest b GET
15 TxURL b
/video/5708047/jeena-jeena-video-song-badlapur-atif-aslam
15 TxProtocol b HTTP/1.1
15 TxHeader b Referer: http://beta2.domain.com/videos/
15 TxHeader b X-Real-IP: 39.49.89.134
15 TxHeader b X-Forwarded-Host: beta2.domain.com
15 TxHeader b X-Forwarded-Server: beta2.domain.com
15 TxHeader b Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
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
15 TxHeader b Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
15 TxHeader b X-Forwarded-For: 39.49.89.134, 127.0.0.1
15 TxHeader b host: default
15 TxHeader b X-GeoIP: Unknown
15 TxHeader b X-Varnish: 1609403517
15 TxHeader b Accept-Encoding: gzip
15 RxProtocol b HTTP/1.1
15 RxStatus b 200
15 RxResponse b OK
15 RxHeader b Date: Tue, 20 Jan 2015 18:26:06 GMT
15 RxHeader b Server: Apache
15 RxHeader b Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1;
expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/
15 RxHeader b Expires: Thu, 19 Nov 1981 08:52:00 GMT
15 RxHeader b Cache-Control: no-store, no-cache, must-revalidate,
post-check=0, pre-check=0
15 RxHeader b Pragma: no-cache
15 RxHeader b Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/
15 RxHeader b Set-Cookie:
pageredir=http%3A%2F%2Fbeta2.domain.com%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/
15 RxHeader b Connection: close
15 RxHeader b Transfer-Encoding: chunked
15 RxHeader b Content-Type: text/html; charset=utf-8
15 Fetch_Body b 3(chunked) cls 0 mklen 1
15 Length b 127024
15 BackendClose b default
12 SessionOpen c 127.0.0.1 51675 :6081
12 ReqStart c 127.0.0.1 51675 1609403517
12 RxRequest c GET
12 RxURL c
/video/5708047/jeena-jeena-video-song-badlapur-atif-aslam
12 RxProtocol c HTTP/1.0
12 RxHeader c Referer: http://beta2.domain.com/videos/
12 RxHeader c Host: beta2.domain.com
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)
12 RxHeader c X-Real-IP: 39.49.89.134
12 RxHeader c X-Forwarded-Host: beta2.domain.com
12 RxHeader c X-Forwarded-Server: beta2.domain.com
12 RxHeader c X-Forwarded-For: 39.49.89.134
12 RxHeader c Connection: close
12 RxHeader c Cache-Control: max-age=0
12 RxHeader c Accept:
text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
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
12 RxHeader c Accept-Language: en-GB,en-US;q=0.8,en;q=0.6
12 VCL_call c recv lookup
12 VCL_call c hash
12 Hash c
/video/5708047/jeena-jeena-video-song-badlapur-atif-aslam
12 Hash c default
12 Hash c Unknown
12 VCL_return c hash
12 VCL_call c miss fetch
12 Backend c 15 default default
12 TTL c 1609403517 RFC 0 -1 -1 1421778367 0 1421778366
375007920 0
12 VCL_call c fetch
12 TTL c 1609403517 VCL 3600 -1 -1 1421778367 -0
12 VCL_return c deliver
12 ObjProtocol c HTTP/1.1
12 ObjResponse c OK
12 ObjHeader c Date: Tue, 20 Jan 2015 18:26:06 GMT
12 ObjHeader c Server: Apache
12 ObjHeader c Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1;
expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/
12 ObjHeader c Expires: Thu, 19 Nov 1981 08:52:00 GMT
12 ObjHeader c Pragma: no-cache
12 ObjHeader c Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/
12 ObjHeader c Set-Cookie:
pageredir=http%3A%2F%2Fbeta2.domain.com%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/
12 ObjHeader c Content-Type: text/html; charset=utf-8
12 VCL_call c deliver deliver
12 TxProtocol c HTTP/1.1
12 TxStatus c 200
12 TxResponse c OK
12 TxHeader c Set-Cookie: PHPSESSID=pcl9rkh58s39fgjti139bgn6n1;
expires=Wed, 21-Jan-2015 18:26:06 GMT; path=/
12 TxHeader c Expires: Thu, 19 Nov 1981 08:52:00 GMT
12 TxHeader c Pragma: no-cache
12 TxHeader c Set-Cookie:
fb_239452059417627_state=42cba63d4821f3964426e14b2833e8d0; expires=Tue,
20-Jan-2015 19:26:06 GMT; path=/
12 TxHeader c Set-Cookie:
pageredir=http%3A%2F%2Fbeta2.domain.com%2Fvideo%2F5708047%2Fjeena-jeena-video-song-badlapur-atif-aslam;
expires=Tue, 20-Jan-2015 20:26:06 GMT; path=/
12 TxHeader c Content-Type: text/html; charset=utf-8
12 TxHeader c Content-Length: 127024
12 TxHeader c Accept-Ranges: bytes
12 TxHeader c Date: Tue, 20 Jan 2015 18:26:06 GMT
12 TxHeader c Age: 0
12 TxHeader c Connection: close
12 Length c 127024
12 ReqEnd c 1609403517 1421778366.722367764 1421778366.841626406
0.000178814 0.119145393 0.000113249
12 SessionClose c Connection: close
12 StatSess c 127.0.0.1 51675 0 1 1 0 0 1 602 127024
0 CLI - Rd ping
0 CLI - Wr 200 19 PONG 1421778367 1.0
15 BackendOpen b default 127.0.0.1 45814 127.0.0.1 7172

Nginx proxy.inc :

proxy_redirect off;
proxy_hide_header Vary;
proxy_set_header Accept-Encoding '';
proxy_ignore_headers Cache-Control Expires;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

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.

Regards.
Shahzaib
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Geoip issue with nginx in front of varnish and apache !

shahzaib1232 January 20, 2015 01:40PM

Re: Geoip issue with nginx in front of varnish and apache !

Francis Daly January 20, 2015 02:08PM

Re: Geoip issue with nginx in front of varnish and apache !

shahzaib1232 January 20, 2015 03:06PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 156
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready