Use nginx for URL-specific load balancing or interface-oriented distribution

Source: Internet
Author: User
: This article describes how to use nginx for URL-based load balancing or interface-oriented distribution. For more information about PHP tutorials, see. Only one method is provided for interface-oriented distribution of location.

The simplest configuration is clear about interface-oriented distribution, and other configurations are not described.

For example, two URLs are requested:

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  65;    upstream sale {        server 192.168.1.100:8000 max_fails=2;     }    upstream matchmaker {        server 192.168.1.200:8080 max_fails=2;     }    server {        listen       80;        server_name  www.000.com;        location /sale {            root /www            proxy_pass  http://sale;        }        location /matchmaker {             root /www             proxy_pass http://matchmaker;        }    }}

Note:

When the request http ://Www.000.com/When sale arrives, listen to the domain name of port 80Www.000.comMatch sale according to location, and then locate the corresponding upstream based on the proxy_pass http: // sale field. then the request will reach 192.168.1.100: 8000.

This achieves load balancing based on url-oriented forwarding.

The above describes how to use nginx to implement load balancing or interface-oriented distribution for URLs, including some content, and hope to help friends who are interested in PHP tutorials.

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.