A recent study of Nginx,nginx as a reverse proxy server provides acceleration to the Web server and features load balancing.
First of all, I want to download Nginx (http://nginx.org/en/download.html) on the official website, the latest version is 1.9.5, Linux and Windows versions I've been down, doing web load balancing on both servers.
In the version of Windows, unzip the package and execute the command:
Start Nginx
This will enable the Nginx service to start. and execute the command:
Nginx-s stop
You can stop the service.
Execute command
Nginx.exe-s Reload
You can reload the configuration file
I'm using a native test, this is my IIS server on 192.168.100.11, add two sites:
These two sites add two files index.html, two file contents respectively: "Port Bayi", "port82".
Configure the host file as follows:
192.168.100.11 test.com
In the nginx.conf configuration file, adjust the relevant configuration:
Upstream test.com{
Server 192.168.100.11:81;
Server 192.168.100.11:82;
}
Listen 80;
server_name 192.168.100.11;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
root HTML;
Index index.html index.htm;
Proxy_pass http://test.com;
}
Proxy_pass http://test.com; This test.com is the address of the domain name configured in the host file, corresponds to the file configuration in the host, and after the file is saved, executes the command
Nginx.exe-s Reload
When you open a browser test and refresh the page, you will switch back and forth between the two sites.
Open the configuration file and modify it as follows:
Upstream test.com{
Ip_hash;
Server 192.168.100.11:81;
Server 192.168.100.11:82;
}
Save, execute command
Nginx.exe-s Reload
In the next test, you will find that the refresh only on one site to access, you can solve the problem of the session.
Nginx Doing load Balancing