Sep 162010
When you have many networks, which are located far apart and in different location. You want users to access the server closest to their network. town1 users when accessing the main server, the server will diredirect town1.example.com, and the town2′s users will be redirected to town2.example.com.
http {
geo $geo {
default default;
1.1.1.0/24 town1;
1.1.2.0/24 town2;
1.1.3.0/24 town3;
...
}
server {
location / {
rewrite ^(.*)$ http://$geo.example.com$1 permanent;
}
...
}
...
}
You may also want to read these posts:
- Nginx, redirecting all request to https
- Nginx – Customizing 404 page
- Nginx Image Hotlink Prevention
- Monitoring And Debugging Memcached Server Using phpMemCachedAdmin
- Nginx Blocking Spoofed Google Bot
- Memcached Replication On Server Clusters
- Nginx And Simple Permalink
- Nginx, Simple Http Authentication Using ngx_http_auth_pam_module Module
- Nginx, limit website visitor bandwidth by country
- Nginx And Unix User Directories
One Response to “Nginx, Geo IP and Distributed Server”
Comments (1)
Follow me on Twitter
Great!