Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I currently have 3 stores online with 3 different domains, running magento with Apache and varnish (using Phoenix page cache extension) running on centos

One store is for uk, another for Ireland and another for USA

Trouble is (Example) If an US user hits the uk store , I would like the user to be notified to go to the correct store on the page, (I do not want them automatically redirected)

I was able to php-pecl-geoip with maxmind database to get this to work, but as users on my website have increased I had to begin using varnish.

how could I implement this functionality on with varnish so I know what country the user is from so I can display a message to the user to view their relevant website?

share|improve this question

1 Answer 1

There's a Varnish module (plug, I modified this version from cosimo's original one) which can help you:

https://github.com/iwebhosting/varnish-geoip

This will add an X-Geo-IP header containing the country code. In your PHP code you can get at it via $_SERVER['X_GEO_IP'], and in Varnish you can make sure different countries see different cached versions of the page with this VCL snippet:

sub vcl_hash {
 hash_data(req.http.X-Geo-IP);
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.