Introduction to Nginx (i) Simple load balancing under window

Source: Internet
Author: User

: http://nginx.org/en/download.html

I am downloading the latest version (nginx/windows-1.11.10)

Decompression run Nginx.exe can see the command line window flashed past, view task Manager, you can see more than two Nginx.exe process

Enter the conf of the extracted directory

This file is the Nginx configuration file, this is the window version, some configuration has been commented out

Configuration details can see this blog http://www.cnblogs.com/sunxucool/p/3225818.html

Enter localhost to see the default page of Nginx

Now to use a Web project to achieve load balancing ...

Change configuration file

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 localhost:8081;  #负载均衡服务器1server localhost:8082;  #负载均衡服务器2}     Server {        listen       ;  #监听端口        server_name  localhost; #监听ip 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;    }}}

This implementation of the principle can be seen from the configuration to hear localhost:80 request redirection to Nginx Pseudo-site http://wgf.com,

Then Nginx is configured to find the end-of-access server addresses localhost:8081 and localhost:8082

These two are my local two Web projects, and access to localhost rotates between the two services. The effect is as follows

Introduction to Nginx (i) Simple load balancing under window

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.