My Load Balancing configure is fail

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_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 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 display “140”.

Posted at Nginx Forum:

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)

Thank you very much. Yu Sun, it works now

Posted at Nginx Forum: