Load balancing, missing a detail

Hi all,

I need your help with setting nginx as load balancer.
I have 2 servers, 192.168.1.2 (Web1) and 192.168.1.3 (Web2), both with
same content into /www/html directory.
Web1 has nginx installed.

http {

upstream webcluster {
server 192.168.1.2:8000;
server 192.168.1.3:8001;
}

ignore_invalid_headers on;
reset_timedout_connection on;
keepalive_timeout 60;

server {
listen 80;
server_name domain.com;
root /var/www/html;
access_log
/var/log/nginx/localhost.access.log main buffer=32k;
error_log
/var/log/nginx/localhost.error.log warn;

client_max_body_size    10m;
client_body_buffer_size    512k;

proxy_buffer_size      32k;
proxy_buffers      16 32k;
proxy_set_header      Host $host;
proxy_set_header      X-Real-IP

$remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;

error_page 404      = /404.html;
error_page 500 502 503 504  = /50x.html;

location / {
  proxy_pass

$scheme://webcluster;
index index.php
index.html;
}
}
}

What am I missing? Do I need to install another software, like
TurboGears?
All I want is to load balance 2 servers who have the exact same
content…

I looked at this example:

If I visit http://192.168.1.2:80/, I can see the site. Not if I go to
http://192.168.1.2:8000/
With the above configuration, I get this error message:
2009/03/23 12:10:42 [error] 27847#0: *1 connect() failed (111:
Connection refused) while connecting to upstream, client: xx.xx.xx.xx,
server: domain.com, request: “GET /forum/ HTTP/1.1”, upstream:
http://192.168.1.3:8001”, host: “domain.com
2009/03/23 12:10:42 [error] 27847#0: *1 connect() failed (111:
Connection refused) while connecting to upstream, client: xx.xx.xx.xx,
server: domain.com, request: “GET /forum/ HTTP/1.1”, upstream:
http://192.168.1.2:8000”, host: “domain.com
2009/03/23 12:10:42 [error] 27847#0: *1 no live upstreams while
connecting to upstream, client: xx.xx.xx.xx, server: domain.com,
request: “GET /forum/ HTTP/1.1”, upstream: “http://webcluster”, host:
domain.com

Please let me know what else I need to configure, in order to enable the
balancer.

Regards,

Floren

Floren M. пишет:

Hi all,

I need your help with setting nginx as load balancer.
I have 2 servers, 192.168.1.2 (Web1) and 192.168.1.3 (Web2), both with
same content into /www/html directory.
Web1 has nginx installed.

Did you read this Module ngx_http_upstream_module ?

What am I missing? Do I need to install another software, like
TurboGears?

No.

All I want is to load balance 2 servers who have the exact same
content…

I looked at this example:
Simple Load Balancing | NGINX

If I visit http://192.168.1.2:80/, I can see the site. Not if I go to
http://192.168.1.2:8000/

You should define a real ports of your backends in the nginx
configuration.
i.e.

http {
upstream backends {
server 192.168.1.2:80;
server 192.168.1.3:80;
}

server {
listen 80;
server_name www.domain.com;
location / {
proxy_pass http://mbackends;
}
}
}

Hi Sergej,

-----Original Message-----
From: Sergej Kandyla [mailto:sk.paix-
[email protected]]
Posted At: Monday, March 23, 2009 12:31 PM
Posted To: gmane.comp.web.nginx.english
Conversation: Load balancing, missing a detail…
Subject: Re: Load balancing, missing a detail…

You should define a real ports of your backends in the nginx
configuration.

I need nginx installed in one server only, right?
Thanks for the above posted info.

Regards,

Floren