NANDAKUMAR THANGAVELU
NANDAKUMAR THANGAVELU

Reputation: 661

Unable to make NginX load balancing

I am new to the nginx config.

I am trying to do a load balancing example with nginx and wcf rest service in windows platform.

Here is what I have in my conf/nginx.conf file:-

upstream servers_customserver {
server 127.0.0.1:62133; 
server 127.0.0.1:64897;
server 127.0.0.1:64921;
}

server {
listen 8070;       

location /test {
proxy_pass  http://servers_customserver/;             
}

My motive is whenever, I try to enter a website name which contains "/test" then redirect to one of the urls in the "servers_customserver".

Nginx is fine in localhost:8070.

But whenever I did localhost:8070/test, I am getting "404 Not Found nginx/1.12.0" in the browser. I am sure that my services are up.

Do, I need to work with my services in IIS or any webservers to make this to work?

Could some one guide me in solving this error.

Thanks.

Upvotes: 1

Views: 609

Answers (1)

NANDAKUMAR THANGAVELU
NANDAKUMAR THANGAVELU

Reputation: 661

Luckily,

After adding the following steps to the location block, the load balancing stuff works for me.

        proxy_set_header   Host   $host;
        proxy_set_header   X-Real-IP  $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Host @server_name;   
        proxy_redirect off;

Thanks.

Upvotes: 1

Related Questions