GeoIp local countries

Hi,
I’m new here and uses nginx for a couple of months as a reverse proxy
for apache since I discovered this server (setup for magento website)
I now need to localize my users, meaning redirecting german users to
domain.de, us ones to domain.com, french ones to domain.fr, etc, and all
others to .com

As I’m running debian servers, I’ve upgraded nginx from 0.6.32 to 0.7.67
–with-http_geoip_module
I have a config file for each of my local domains in sites-avalaible /
sites-enabled with both config for 80 & 443 ports in “server” directive

domain.com :

server {
        listen   80;
        server_name domain.com;
        bla bla
        location / {
              proxy_pass http://.......
        }
server {
        listen   443;
        server_name domain.com;
        bla bla
        location / {
              proxy_pass https://.......
        }
}

I wonder how and where to put the directives like :

if ($geoip_country_code = FR) {
rewrite ^(.*)$ http://domain.fr$1 permanent;
}
if ($geoip_country_code = DE) {
rewrite ^(.*)$ http://domain.de$1 permanent;
}
...

as I would like not to write those in each vhost in order for
maintenance to remain efficient and as I would like to avoid redirection
loops…
I tried to put them directly in conf.d/geo.conf but it seems they have
to be under a server directive…

Any idea ?
Thanks in advance for your help

Best

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,127911,127911#msg-127911

Testing in domain.fr vhost file

if ($geoip_country_code = FR) {
rewrite ^(.*)$ http://domain.de$1 permanent;
break;
}

while being in France (to see if geoip rules), I fall in a loop,
redirecting to domain.de (so I assume this part is ok), then asking for
domain.fr again , etc.

Where am I wrong ?

Tks

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,127911,127997#msg-127997

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs