The content of this article is about the configuration introduction (code) of Nginx location. The content is very detailed. Friends in need can refer to it. I hope it can help you.
location is based on Uri To perform different positioning, location can position different parts of the website to different processing methods. The syntax of
is:
location [=|~|~*|^~] patt { } //The brackets are modifiers. You don’t need to write any parameters. This is called a general match. You can also write parametersTherefore,large types can be divided into three types:
Location = patt {} [Accurate Match]
Location patt{} [Normal matching]
Location ~ patt{} [Regular matching]
Let’s first look at a picture to understand the priority of matching:server { listen 80; server_name localhost; location =/text.html { #精准匹配,浏览器输入IP地址/text.html,定位到服务器/var/www/html/text.html文件 root /var/www/html; index text.html; } location / { #普通匹配,浏览器输入IP地址,定位到服务器/usr/local/nginx/html/default.html文件 root html; index default.html; } location ~ image { #正则匹配,浏览器输入IP/image..地址会被命中,定位到/var/www/image/index.html root /var/www/image; index index.html; } }
How to configure nginx load balancing? nginx load balancing configuration method
#How does php achieve load balancing? PHP load balancing example (code)
The above is the detailed content of Nginx location configuration introduction (code). For more information, please follow other related articles on the PHP Chinese website!