You are here

Creating an IIS cluster with load balancing with nginx


Good afternoon, below will be told how to create a failover cluster with load balancing. We will balance the load with nginx, because IIS ARR 1) requires add. License for Windows, 2) can not monitor the http responses of several sites.

Let's get started.

First, I'll install the IIS itself, 2 pieces (you can have more =)). This procedure will not show here everything is clear-understand, go to the server manager, add the role of the web server to our servers.

In the meantime, while IIS is going to share 2 folders on some server (preferably not on where our web servers are). 1 folder for storing the configuration of IIS, the second for storing sites.

 

Next we need to install addhelper on both servers, you can download here.

It is needed to ensure that the correct IP addresses of site visitors are written in the IIS header, otherwise the address of the balancer will always be.

Next, after both iis installed, copy (if you need a default site) the contents of the folder c:\inetpub\wwwroot in our shared folder for sites (not forgetting to create a folder for the default site in it)

After that, we go to the IIS management console, go to the default site, go to the main settings and register our network path to the site.

Then click on our server and go to the general configuration, click on the export configuration, specify the network path to the shared folder where the IIS configuration will be located, and enter the password for the encryption keys. Click OK.

Next, we use the common configuration, enter the address of the location where our configuration is, click on apply and enter our password.

Next, you need to register the user on behalf of which the application pools are started, and who has access to our network folders. To do this, you need to log in to the authentication, and change the anonymous authentication. You can put a check by the application pool, or select a domain user.

Further we try to open our site if it was opened it is possible to continue, if not, then something is done wrong.

We pass to our second server. We do not forget to put ARRhelper, and we connect the common configuration, similarly as we did with the first server.

For ease of testing, you can fill in the following unpretentious asp page on the site - /sites/default/files/files/default.aspx, it shows the server address, client address and site name.

The IIS configuration is completed, now go on to configuring nginx. I bet on ubuntu, you can bet on anything, it does not matter.

Actually put nginx - sudo apt-get install nginx

After the installation of the rule config - sudo nano/etc/nginx/sites-enabled/default

My config is like this:

#Our web servers
    upstream web_servers {
        server 192.168.0.11;
        server 192.168.0.12;
        }
 #Which port to listen
    server {
        listen 80;
        location / {
                #Proxy
                proxy_pass http://web_servers;
                #Installation of the header
                proxy_set_header X-proxy 192.168.0.13;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                #From this header arrhelper takes ip
                proxy_set_header X-Forwarded-For $remote_addr;
                proxy_set_header X-Forwarded-Proto $scheme;
                #Setting errors that nginx will try to access on the next server
                proxy_next_upstream     error timeout invalid_header http_500 http_404;
                proxy_set_header X-Client-IP $remote_addr;
                }
        }

Restart nginx - sudo /etc/init.d/nginx restart If you have not issued any errors, then everything should work.

At this, for now, it's all, you can try to register your nginx address in the DNS for your site and go to the site, you will see that the requests come to different servers (in this case, by default, balancing is round robin, nginx also has hash etc) ..

You can also watch the video instruction (it is on Russian Language):

0 0

Share the article with your friends in social networks, maybe it will be useful to them.


If the article helped you, you can >>thank the author<<