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