IIS web server

Building IIS Web Farm with Load Balancing using Nginx

This article describes how to create a web farm with load balancing on Internet Information Services (IIS) 8.0 and higher. Load balancing between Web servers in the farm will be implemented not by the standard extension for IIS Application Request Routing (ARR), but using an open source HTTP/reverse proxy Nginx.

Nginx is a simple, fast and reliable HTTP server. Nginx is used primarily for static websites and as a a front proxy before high load dynamic sites. Nginx is designed for the purpose of rapid processing of requests and able to serve static requests, perform proxy caching and simple load balancing functions.

Tip. The main disadvantages of Application Request Routing is that it can’t monitor HTTP responses from several sites and requires additional Windows license.

Building IIS Web Farm

In our example, the IIS Web farm consists of two IIS servers based on Windows Server 2012 R2 and front-end Linux server with Nginx. If it is necessary, you can easily scale this scheme by adding any number of additional IIS servers. Nginx can hide behind itself a hundred of web servers (backend) and distributed queries on a wide set of rules between them. Disconnecting any of the IIS server will not affect the system availability.

READ ALSO  How to Install and Configure phpMyAdmin on IIS in Windows 8/Server 2012

nginx iis

First of all, it is necessary to install IIS role on both Windows servers. You can do this from the Server Manager console or by using PowerShell:

import-module servermanager
Install-WindowsFeature -Name Web-Server, Web-Mgmt-Tools

server roles web server

We need a separate Windows file server on which are located two network folders:

  • The first will store IIS configuration – \\srv1\iis_config
  • the second – sitefiles – \\srv1\iis_site

iis site

Give the Everyone group Full Control permissions on the both network shares.

iis config permissions

Next we need to install the extension ARR Helper on both servers. This extension is necessary in order to record the correct IP addresses of visitors to the IIS headers, otherwise they will always be given an Nginx address. This extension is a part of the IIS Application Request Routing package (ARR) 3.0 and can be manually copied from the directory %ProgramFiles%\IIS\Application Request Routing\requestrouterhelper_x64.msi.

Once the IIS installed, you need to copy the contents of a folder c:\inetpub\wwwroot to a network folder \\srv1\iis_site. After that, go to the IIS management console, select the DefaultWebSite, go to the Basic Settings and specify the network path to the site folder.

edit site

Now select the server and navigate to the Shared Configuration section and click on Export Configuration.

iis shared configuration

Specify the full network path to network folder with IIS configuration and then specify a password for the encryption keys.

READ ALSO  How to set CPU Usage limit for Application Pool on IIS 8

iis export configuration

Then select «Enable shared configuration» and enter path to the folder with IIS configuration. Click Apply and enter the password.

iis shared location

Next you need to specify the user on whose behalf the application pools are started, and who has access to our network folders. To do this, go to the Authentication section, and change the anonymous authentication. You can select an application pool identity or you can select a domain user.

anonymous credential

Now try to open your site, if successfully you can continue.

Proceed to your second server. Do not forget to install ARRhelper, and connect the shared configuration in the same way as you did with the first server.

We finished setting the configuration of IIS, now we proceed to configure of Nginx. Install Nginx using command:

sudo apt-get install nginx

After installing, edit config file /etc/nginx/sites-enabled/default

In our case, configuration is as follows:

#your web server address

    upstream web_servers {




 #listen port

    server {

        listen 80;

        location / {

                proxy_pass http://your_site.name;

                # headers setting

                proxy_set_header X-proxy;

                proxy_set_header Host $host;

                proxy_set_header X-Real-IP $remote_addr;

                proxy_set_header X-Forwarded-For $remote_addr;

                proxy_set_header X-Forwarded-Proto $scheme;

                # Errors, on which nginx try to go to 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

Thats all, you can try to register in the DNS for your website address of your Nginx and visit the site. You will see that the requests come on different server (in this case, the default round robin balancing used).

READ ALSO  How to Install and Configure IIS Web Server with PHP support on Windows 8/Server 2012

You may also like:

How to Install and Configure phpMyAdmin on IIS in ... PHPMyAdmin is a web-based open source tool written in PHP designed to help manage MySQL database through the Web browser. Because of this PhpMyAdmin f...
How to Setup an FTP Server in Windows 10 Today we will show you how to setup and access an FTP server in Windows 10. At first let’s create an FTP folder. This folder will be accessed by our F...
How to set CPU Usage limit for Application Pool on... The important function of web server is the ability to limit the CPU usage for a specific site, otherwise one website can use all the CPU resources, t...
How to Delete IIS Log Files on Windows Server 2012 IIS (Internet Information Services) Web Server on Windows Server generates a sufficiently large amount of log files during its work. The main problem ...
How to Install and Configure IIS Web Server with P... This guide will show you how to deploy your own IIS Web server, and enable it to run PHP on Windows 8 / Windows Server 2012. Thereafter this platform ...