2
**NGINX LOad Balancing**

Am trying to load balance my servers hosted in IIS using nginx. If i shut down one of the app pool, nginx should stop sending requests to that server. But what I am seeing nginx will keep sending requests to both servers.Below is my configuration.

       events {
        worker_connections  2048;
    }


    http {
        include       mime.types;
        default_type  application/octet-stream;

        sendfile        off;
        #tcp_nopush     on;

        keepalive_timeout  0;  

      upstream xxx {

            server xxxxxxx:80 max_fails=1  fail_timeout=30;
            server xxxxxxxx:80 max_fails=1  fail_timeout=30;
        }

        server {
            listen       zzzz;
            server_name  localhost;


            location /yy {

                proxy_cache off;
               proxy_redirect off;
               proxy_set_header   X-Real-IP            $remote_addr;
               proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
               proxy_set_header   X-Forwarded-Proto $scheme;
               proxy_set_header   Host                   $http_host;
               proxy_set_header   X-NginX-Proxy    true;
               proxy_set_header   Connection "";

               proxy_http_version 1.1;      
              proxy_pass    http://xxx;
            }
        }

Nginx will still keep sending the requests to the other server even though i have shut down the app pool.

      <HTML>
<HEAD>
    <TITLE>Service Unavailable</TITLE>       
</HEAD>
<BODY>
    <h2>Service Unavailable</h2>
    <hr>
    <p>HTTP Error 503. The service is unavailable.</p>
</BODY>
  </HTML>
Jitin
  • 41
  • 4
  • An application pool is not a server, and this set up would only work if you shutdown IIS on the web server, if I'm not mistaken. – Jan Reilink May 24 '16 at 12:15
  • I meant shutting down the app pool. Even if i shut down the iis server, nginx keeps returning back 404 statuys. ideally it should have unsubscribed. – Jitin May 24 '16 at 16:03

1 Answers1

0

if I'm not wrong,Nginx still continue to call that server because he doesn't find something strange...port 80 is reachable and you must change checking method to find an http error.For example this one : https://www.nginx.com/resources/wiki/modules/healthcheck/ ...if the http response is not a 200,he consider that server "bad" and he removes it from the pool.

Simone
  • 1
  • 1