Nginx load balancer with GeoIP


#1

Hi there,

Is nginx will support load balancing with GeoIP support?

Example :

If match country US

            Proxy_pass http://us.server/;

If match other

            Proxy_pass http://default.server/;

Regards,

Glen L.


#2

On Tue, Nov 11, 2008 at 10:10:42AM +0700, Glen L. wrote:

If match other

            Proxy_pass http://default.server/;

http {
geo $geo {
default default;
1.1.1.0/24 us;
1.1.2.0/24 us;
1.1.3.0/24 us;

}

  upstream  us.server {
      ....
  }

  upstream  default.server {
      ....
  }

  server {
       location / {
           proxy_pass  http://$geo.server;
       }

#3

How do I spread connection if I use
./geo2nginx.pl GeoIPCountryWhois.csv > geo.conf

Regards,

Glen L.


#4

If our protocol is RTSP which is using port 554, is that posibble to
load
balancing with nginx?
If yes, how can I do it? Because I got 400 Error (Bad Request) on
access.log

Regards,

Glen L.


#5

When using it for HTTP request, it show me error on my browser

Bad Request

Your browser sent a request that this server could not understand.

Here’s my configuration

geo $geo {
    default default;
include geo.conf;
}

upstream ID.server {
    server 10.50.12.123;
}

upstream default.server {
    server 1.2.3.4;
}

server {
listen 10.50.12.134:80;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://$geo.server;

Anyone know how to fix this?

Regards,

Glen L.


#6

On Wed, Nov 12, 2008 at 02:35:03PM +0700, Glen L. wrote:

If our protocol is RTSP which is using port 554, is that posibble to load
balancing with nginx?
If yes, how can I do it? Because I got 400 Error (Bad Request) on access.log

No, only HTTP is supported.


#7

On Wed, Nov 12, 2008 at 02:49:10PM +0700, Glen L. wrote:

include geo.conf;

server {
listen 10.50.12.134:80;

location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_pass http://$geo.server;
  •     proxy_pass http://$geo.server;
    
  •     proxy_pass http://$geo.server$request_uri;

#8

Thank’s Igor it’s works successfull.

Onother question is, are we using the Load Balancer bandwidth also to
send
the data to the client?
Because what we do is, I’m mirroring the server in my country, and I
have
onother server which is located in US

Also, I already install mod_rpaf on the apache, and set
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://$geo.server$request_uri;

But what I received on the apache logs, is still the load balancer IP,
not
the public IP

Regards,

Glen L.


#9

On Wed, Nov 12, 2008 at 04:03:57PM +0700, Glen L. wrote:

    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_pass http://$geo.server$request_uri;

But what I received on the apache logs, is still the load balancer IP, not
the public IP

You should add mod_rpaf ( http://stderr.net/apache/rpaf/ ) to Apache.


#10

Will onother protocol be supported? Such as streaming and mysql load
balancing

Regards,

Glen L.

Sent from my BlackBerry®


#11

On Wed, Nov 12, 2008 at 09:40:29AM +0000, removed_email_address@domain.invalid wrote:

I already install and load mod_rpaf like already described from my previous email

Sorry, I’ve missed this line.

Can describe what address you see in this form:

1.1.1.1 (LB) > 2.2.2.2 (nginx) > 3.3.3.3 (apache)

?

What do you use as Load Balancer ?


#12

I already install and load mod_rpaf like already described from my
previous email

Regards,

Glen L.

Sent from my BlackBerry®


#13

Right now I just use
1.1.1.1 (nginx) > 2.2.2.2 (apache)
> 3.3.3.3 (apache) --> located on different country

Nginx load balanced with 2 apache servers.

Also what about the bandwidth that’s used for accessing 3.3.3.3? It’s
using
1.1.1.1 bandwidth to access 3.3.3.3?

Regards,

Glen L.


#14

Sorry please ignore my previous email. I forgot to enable the rpaf with
RPAFenable On
RPAFproxy_ips 127.0.0.1 REALIP1 REALIP2
RPAFsethostname On

How about the bandwidth issue?

Regards,

Glen L.