Arun
Arun

Reputation: 3680

To test Nginx load-balancing in local system

I wanted to test if nginx is redirecting to node-2 if node-1 is down.

For that, I installed tomcat in my local windows machine and started 2 instances in 8080 and 9090 port

Dont know how to configure nginx for this. I tested by adding below blocks in nginx.conf . But still it is not working for me. Please help me on this

proxy_redirect ~.*:909[0-9]/(.*)$ /$1;
proxy_redirect ~.*:808[0-9]/(.*)$ /$1;

upstream localhost {

        server localhost:8080;
        server localhost:9090;
    }


server {
        listen 8080;
        server_name localhost;

    }

Upvotes: 1

Views: 2776

Answers (1)

Pardeep Singh
Pardeep Singh

Reputation: 422

Replace the server block by below block

server {
       listen 8080;
       location / {
              proxy_pass http://localhost;
            }
        }

Upvotes: 4

Related Questions