First, install the Nginx on Windows
1, download nginx version of Windows from here
2. Extract the compressed file into the C-packing directory and rename the folder to Nginx
3, in the Conf directory in the nginx.conf file, specify a not conflicting port number, where the test with 8088, the code snippet is as follows:
server {
Listen 8088;
server_name localhost;
}
4, open the cmd command line, run the following command:
>CD C:\nginx
>nginx
OK, try it, open the browser, enter the 127.0.0.1:8088, if the following figure, it shows that the Nginx server has been successfully installed and already running.
Second, a simple configuration, to engage in a load-balanced cluster test environment
Here I have only one computer, 2G of memory, because do not do performance testing, use the virtual machine, I use the virtual machine VMware, the following description of the entire test environment:
* Physical host one, Cpu:core2 t5750,2g memory, Windows 7 operating system, IP address 192.168.1.98, host name SXWGF-PC, which is used as a 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, host name HZDK-VPC, which is used as another Web server (B)
1, open the Conf directory under the NGINX.CONF, the specific configuration code 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 and then the previous installation of the method to start Nginx, you can also directly enter the command: nginx-s Reload to restart
3, prepare two identical asp.net test website program, put in host A and virtual Host B IIS respectively, enter corresponding IP address to try it:
Input 192.168.1.98
Input 192.168.1.99
Finally, we'll visit our Nginx Proxy server, let's see if he can get us access to real servers A and B, the result is to switch between A and b every time we refresh, as if we were visiting A and b in rounds, but we're ostensibly a proxy server 127.0.0.1 : 8088, here is a screenshot:
Once refreshed:
This is the result of simple polling access, to some extent, the role of load streaming, of course, this is the simplest, more advanced usage is being studied ... Thanks for reading.