Windows configuration nginx for load Balancing cluster

Source: Internet
Author: User
Tags nginx server nginx load balancing

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:

  1. server {
  2. Listen 8088;
  3. server_name localhost;
  4. }

4. Open the cmd command line and run the following command:

  1. >CD C:\nginx
  2. >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:

  1. Worker_processes 1;
  2. Events {
  3. Worker_connections 1024;
  4. }
  5. HTTP {
  6. Include Mime.types;
  7. Default_type Application/octet-stream;
  8. Sendfile on;
  9. Keepalive_timeout 65;
  10. Upstream wgf.com{
  11. Server 192.168.1.98; #真实服务器A (SXWGF-PC)
  12. Server 192.168.1.99; #真实服务器B (HZDK-VPC)
  13. }
  14. server {#Nginx代理服务器
  15. Listen 8088;
  16. server_name localhost;
  17. Location/{
  18. root HTML;
  19. Index index.html index.htm;
  20. Proxy_pass http://wgf.com;
  21. Proxy_redirect default;
  22. }
  23. Error_page 502 503 504/50x.html;
  24. Location =/50x.html {
  25. root HTML;
  26. }
  27. }
  28. }

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.