Use Nginx for URL-based load balancing or interface directed distribution

Source: Internet
Author: User
This provides only one way to direct the interface for location distribution.

The simplest configuration makes it clear that the interface is directed for distribution and is not explained for other configurations.

For example, request two URLs:

1), Www.000.com/sale

2),www.000.com/matchmaker

#user  nobody;worker_processes  1;events {    worker_connections  1024;} HTTP {    include       mime.types;    Default_type  Application/octet-stream;    Sendfile on        ;    Keepalive_timeout  ;    Upstream Sale {        server 192.168.1.100:8000 max_fails=2;     }    Upstream Matchmaker {        server 192.168.1.200:8080 max_fails=2;     }    server {        listen       ;        server_name  www.000.com;        Location/sale {            root/www            proxy_pass  http://sale;        }        Location/matchmaker {             root/www             proxy_pass http://matchmaker;        }    }}

Description

When the request HTTP/www.000.com/sale arrives, the domain name of the listening port 80 port is www.000.com based on location to sale, and then according to the field Proxy_pass Http://sale to find the corresponding upstream, then the request will arrive 192.168.1.100:8000 this machine.

It's done. Load balancing based on URL directed forwarding

The above describes the use of Nginx for the URL to achieve load balancing or interface directed distribution, including the aspects of the content, I hope 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.