# My Load Balancing configure is fail

**URL:** <https://www.ruby-forum.com/t/my-load-balancing-configure-is-fail/185384>\
**Category:** NGINX\
**Created:** [March 19, 2010, 3:13am UTC](https://www.ruby-forum.com/t/my-load-balancing-configure-is-fail/185384 "2010-03-19T03:13:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 19, 2010, 3:13am UTC](https://www.ruby-forum.com/t/my-load-balancing-configure-is-fail/185384/1 "2010-03-19T03:13:00Z")

</div>

I config load balancing in my main server.  
But after I config it,it alway visit server 192.168.1.140, and display  
“140”.  
Why it do not go to [http://192.168.1.124](http://192.168.1.124) in 50%?

My main server 192.168.1.124 nginx.conf file:

user daemon;  
worker\_processes 2;

error\_log logs/error.log info;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;  
server\_tokens off;  
sendfile on;

```
keepalive_timeout 65;
#gzip on;
client_max_body_size 40m;

upstream myproject {
    server 192.168.1.140:80 weight=5;
    server 192.168.1.124:80 weight=5;
}
server {
    listen 80;
    server_name 192.168.1.124;

    location / {
        proxy_pass http://myproject;
        root /home/httpd/html;
        index index.html index.htm index.php;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 

```

/home/httpd/html/$fastcgi\_script\_name;  
include fastcgi\_params;  
}  
location /NginxStatus/ {  
auth\_basic “NginxStatus”;  
auth\_basic\_user\_file conf/htpasswd;  
access\_log off;  
}  
}

}

and visit [http://192.168.1.124](http://192.168.1.124) display “124”.

My second server 192.168.1.140 nginx.conf file:

#user nobody;  
worker\_processes 2;

error\_log /var/log/nginxerror.log info;

events {  
worker\_connections 1024;  
}

http {  
include mime.types;  
default\_type application/octet-stream;  
server\_tokens off;  
sendfile on;  
keepalive\_timeout 65;  
#gzip on;

```
server {
    listen 80;
    server_name 192.168.1.140;
    location / {
        root /home/httpd;
        index index.html index.htm index.php;
    }
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root html;
    }
    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME 

```

/home/httpd/$fastcgi\_script\_name;  
include fastcgi\_params;  
}  
}  
}  
and visit [http://192.168.1.140](http://192.168.1.140) display “140”.

Posted at Nginx Forum:

> **[My Load Balancing configure is fail.](https://forum.nginx.org/read.php?2,65471,65471#msg-65471)**
>
> I config load balancing in my main server. But after I config it,it alway visit server 192.168.1.140, and display "140". Why it do not go to http://192.168.1.124 in 50%? My main server 192.168.1.124 nginx.conf file: user daemon; worker\_p

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 20, 2010, 4:18am UTC](https://www.ruby-forum.com/t/my-load-balancing-configure-is-fail/185384/2 "2010-03-20T04:18:05Z")

</div>

you can try this:  
1.configure two nginx instance at 192.168.1.124 in two ports(one for 80  
and the other for 8080).  
in the 80 nginx.conf, use upstream  
upstream myproject {  
server 192.168.1.140:8080;  
server 192.168.1.124:8080;  
}

in the 8080 nginx.conf, do not set up proxy config

1. at 192.168.1.140 set up the 8080 nginx instance without the proxy  
config.

you should seperate the proxy server(192.168.1.140:80) and the  
backends(192.168.1.140:8080,192.168.1.124:80)

---

<div class="post-metadata">

**Author:** ![ultrawind](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/73ab20/32.png) [@ultrawind](https://www.ruby-forum.com/u/ultrawind)\
**Post date:** [March 22, 2010, 4:40am UTC](https://www.ruby-forum.com/t/my-load-balancing-configure-is-fail/185384/3 "2010-03-22T04:40:26Z")

</div>

Thank you very much. Yu Sun, it works now

Posted at Nginx Forum:

> **[Re: My Load Balancing configure is fail.](https://forum.nginx.org/read.php?2,65471,66469#msg-66469)**
>
> I config load balancing in my main server. But after I config it,it alway visit server 192.168.1.140, and display "140". Why it do not go to http://192.168.1.124 in 50%? My main server 192.168.1.124 nginx.conf file: user daemon; worker\_p
