February 25, 2011 01:26PM
Hi everyone,

Has anyone got ngix + load balancing + geoip working nicely?

I have a nginx server load balancing two webservers and would like to add in GeoIP to the mix.

Config :

My config file.

worker_processes 1;

events {
worker_connections 1024;

http {
### SET the path to the .dat file used for determining the visitor's country from the IP-address ###
geoip_country /var/lib/GeoIP/GeoIP.dat;

### SET FASTCGI Variables ###
fastcgi_param GEOIP_COUNTRY_CODE $geoip_country_code;
fastcgi_param GEOIP_COUNTRY_CODE3 $geoip_country_code3;
fastcgi_param GEOIP_COUNTRY_NAME $geoip_country_name;

include mime.types;
default_type application/octet-stream;

sendfile on;

keepalive_timeout 65;

upstream webcluster {
server websvr01:80;
server websvr02:80;


server {
location / {
proxy_pass http://webcluster;
proxy_set_header Host $host;

#error_page 404 /404.html;

# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;




I would like to set it up that those in the UK goto certain webservers, those in USA goto another set of servers and so on.

Appreciate any help or feedback.

Take care and have a great weekend.
Subject Author Posted

NGINX + Load Balancing + GeoIP

tainted February 25, 2011 01:26PM

Re: NGINX + Load Balancing + GeoIP

i-comers March 10, 2011 09:01PM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

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