Nginx configuration round-robin shunting-load balancing [tested]

Source: Internet
Author: User
Nginx configuration round-robin shunting-achieve load balancing [pass test] preparations, 3 servers, or open a virtual machine! I implement it on a virtual machine. The ip addresses are 192.168.1.10192.168.1.11192.168.1.12 (Environment: ngixn is installed without any configuration )... nginx configuration round-robin shunting-achieve load balancing [pass test] preparations, 3 servers, or open a virtual machine! I implement it on a virtual machine. The ip addresses are 192.168.1.10 192.168.1.11 192.168.1.12 (Environment: ngixn is installed without any configuration). The three server environments are the best. I cloned them directly from the vm. The environment is definitely the same! Not the same. I guess I have encountered many strange problems and have never tried them. 192.168.1.10 is used as the server load balancer server (server load balancer will be configured here later, and the other two servers do not need to be configured) first, let's take a look at some common load knowledge. The nginx upstream currently supports four allocation methods. 1) Round Robin (default). each request is distributed to different backend servers one by one in chronological order, if the backend server is down, it can be removed automatically. 2) weight specifies the polling probability. weight is directly proportional to the access ratio, which is used when the backend server performance is uneven. 2) ip_hash: each request is allocated according to the hash result of the access ip address, so that each visitor accesses a backend server at a fixed time, which can solve the session problem. 3) fair (a third party) allocates requests based on the response time of the backend server. requests with short response time are prioritized. 4), url_hash (third-party) can be configured. Open nginx at 192.168.1.10. in the configuration file, add the following code [html] upstream www.129.com {server 192.168.1.11: 80; server 192.168.1.12: 80;} server {listen 80; server_name www.juzheke.com; location/{proxy_pass http://www.juzheke.com ; Required Host $ host; proxy_set_header X-Real-IP $ remote_addr; proxy_set_header X-Forwarded-For $ response;} access_log logs/access_log; error_log logs/error_log;} practice result: http://www.juzheke.com By modifying the host to point to 192.168.1.10, I modified the html vi/usr/local/nginx/html/index.html on the ngixn development page and added index.html to display that the local ip addresses 192.168.1.11 and 192.168.1.12 must be modified. in this way, I entered http://www.juzheke.com Every time you refresh the page, you will jump to the page on different servers (of course, this is to be obvious, so we use the round robin method. you can modify it as needed)

Related Article

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.