Welcome! Log In Create A New Profile

Advanced

Simple Load Balancing on Windows

Posted by Gepporello 
Simple Load Balancing on Windows
June 02, 2016 05:12AM
Hello everybody,
I'm new to Nginx and I followed the instructions on the website to setup a very simple Load Balancer.
I have a rest web service running on two servers on port 10002:
- server1.domain.com:10002/info
- server2.domain.com:10002/info

So I installed Nginx on a 3rd server (server3.domain.com) and setup the nginx.conf as follow:

upstream loadbal {
server server1.domain.com;
server server2.domain.com;
}

server {
listen 10002;

location / {
proxy_pass http://loadbal;
}
}

When I log on server3.domain.com and try to execute the following: localhost:10002/info
I would expect the request to be redirected to either server1 or server2.
Instead after a while it just times out.

In the error log I can see:
2016/06/02 10:07:45 [error] 6088#5796: *143 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while connecting to upstream, client: 127.0.0.1, server: , request: "GET /info HTTP/1.1", upstream: "http://<server2 IP address>:80/info", host: "localhost:10002"

I don't understand why it's trying to reach port 80 of server2.

I've also tried to change the config as follow, but didn't make any difference:
upstream loadbal {
server server1.domain.com:10002;
server server2.domain.com:10002;
}
Any idea?
Thank you!
Re: Simple Load Balancing on Windows
June 02, 2016 08:16AM
After changing the config make sure nginx is using it, taskkill nginx to be sure.

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Simple Load Balancing on Windows
June 02, 2016 08:55AM
I have done that thank you.
Any idea why it's looking for port 80?

http://<server2 IP address>:80
Re: Simple Load Balancing on Windows
June 02, 2016 09:29AM
80 is the default unless specified for each node, ea;

upstream myLoadBalancer {
server 127.0.0.1:9001 weight=1 fail_timeout=5;
server 127.0.0.1:9002 weight=1 fail_timeout=5;
}

---
nginx for Windows http://nginx-win.ecsds.eu/
Re: Simple Load Balancing on Windows
June 02, 2016 09:49AM
Thank you! It works now, the trick was as you said to kill the process. NGINX -s reload doesn't work.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 144
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready