GeoIp local countries
soisita
nginx-forum at nginx.us
Tue Sep 7 15:37:58 MSD 2010
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
Posted at Nginx Forum: http://forum.nginx.org/read.php?2,127911,127911#msg-127911
More information about the nginx
mailing list