Welcome! Log In Create A New Profile

Advanced

GeoIp local countries

September 07, 2010 07:37AM
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

[u]domain.com :[/u]
[code]
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://.......
}
}
[/code]

I wonder how and where to put the directives like :

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


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
Subject Author Posted

GeoIp local countries

soisita September 07, 2010 07:37AM

Re: GeoIp local countries

soisita September 07, 2010 11:10AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 181
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