Simple Nginx Load Balance example

Source: Internet
Author: User
Tags nginx load balancing
MORE: http://www.webyang.net/Html/web/article_137.html

Nginx is configured to run in the form of a reverse proxy, and the actual processing of the request needs to be forwarded to the backend server for execution. Back-end servers may have one or more, how to choose a suitable back-end server to handle the current request is the Nginx load balancing.

Nginx can not only be a powerful Web server, but also as a reverse proxy server, and Nginx can also follow the schedule rules to achieve dynamic, static page separation, you can follow the polling, IP hash, url hash, weight and other ways to load balance the backend server.

If there is only one server, the server hangs up, then it is a disaster for the website. As a result, load balancing at this time will be a kick-off, and it will automatically eliminate the servers that are hung up.

Load Balancer Module Load-balance is an auxiliary module, mainly for the upstream module service, the goal is clear and single: How to choose a suitable server from multiple back-end servers to handle.

Simple example:
 
 
  1. http {
  2. upstream MyProject {
  3. Server 127.0 . 0.1 : 8000 Weight = 3 ;
  4. Server 127.0 . 0.1 : 8001 ;
  5. Server 127.0 . 0.1 : 8002 ;
  6. Server 127.0 . 0.1 : 8003 ;
  7. }
  8. Server {
  9. Listen the ;
  10. server_name www . Domain . com ;
  11. Location / {
  12. Proxy_pass http : //myproject;
  13. }
  14. }
  15. }
Other normal configurations are available.

Today is the beginning of the Big five, I wish you a happy New Year! In addition: study together, make progress together ~

The above describes the simple nginx load balance example, including aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • 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.