Most of the online tutorials on nginx load Balancing clusters are Linux environments. How to implement a load Balancing cluster in Windows configuration Nginx, install nginx1 on windows, download Nginx
Most of the online tutorials on nginx load Balancing clusters are Linux environments. How to implement a load Balancing cluster in Windows configuration Nginx
First, install Nginx on Windows
1. Download Nginx Windows version Http://sysoev.ru/nginx/nginx-0.8.50.zip
2, unzip the compressed file to the C packing directory, and rename the folder to Nginx
3, in the Conf directory of the nginx.conf file, specify a non-conflicting port number, here test with 8088, the code snippet is as follows:
- server {
- Listen 8088;
- server_name localhost;
- }
4. Open the cmd command line and run the following command:
- >CD C:\nginx
- >nginx
OK, try it, open the browser, enter 127.0.0.1:8088, if it appears, it means that the Nginx server has been successfully installed.
Second, Configuration nginx Load Balancer cluster
* Physical host one, Cpu:core2 t5750,2g memory, Windows 7 operating system, IP address 192.168.1.98, hostname sxwgf-pc, this host is used as an Nginx proxy server (P) and a Web server (a)
* Open a virtual host in the physical host, Windows Server 2003 operating system, IP address 192.168.1.99, hostname hzdk-vpc, the host is used as another Web server (B)
1, open the Conf directory under the NGINX.CONF, the specific configuration code is as follows:
- Worker_processes 1;
- Events {
- Worker_connections 1024;
- }
- HTTP {
- Include Mime.types;
- Default_type Application/octet-stream;
- Sendfile on;
- Keepalive_timeout 65;
- Upstream wgf.com{
- Server 192.168.1.98; #真实服务器A (SXWGF-PC)
- Server 192.168.1.99; #真实服务器B (HZDK-VPC)
- }
- server {#Nginx代理服务器
- Listen 8088;
- server_name localhost;
- Location/{
- root HTML;
- Index index.html index.htm;
- Proxy_pass http://wgf.com;
- Proxy_redirect default;
- }
- Error_page 502 503 504/50x.html;
- Location =/50x.html {
- root HTML;
- }
- }
- }
2, restart the Nginx bar, you can in the task manager of the original two nginx process end and then the previous installation method to start Nginx, you can also directly enter the command: nginx-s Reload to restart
3, prepare two exactly the same ASP. NET Test website program, put in host A and virtual Host B IIS, enter the corresponding IP address try it:
Input 192.168.1.98
Input 192.168.1.99
Finally, we will visit our Nginx Proxy server to see if he can get us to the real servers A and B, the access result is to switch between A and b every time we refresh, as if we were in a round to access a and B, but we are on the surface of the proxy server 127.0.0.1 : 8088, the following are:
Once refreshed:
This is the result of a simple polling access, to a certain extent, the role of load shunt
At this point, the Windows configuration Nginx implementation Load Balancer cluster has been completed.
Windows configuration nginx for load Balancing cluster