Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of matching rules in nginx

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you the example analysis of matching rules in nginx, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Nginx location

The equal sign type (=) has the highest priority and requires an exact match. Once the match is successful, no other matches are found.

^ ~ type expression. Once the match is successful, no other matches are found.

The regular expression type (~ *) takes second priority. If the regularities of multiple location can match, the one with the longest regular expression is used.

(location =) > (location full path) > (location ^ ~ path) > (location ~, ~ * regular order) > (location partial start path) > (/)

The problem of configuring proxy_pass path with / in nginx

The url accessed by the user is http://klvchen.com/abc/test.html

Eg:

# case 1: proxy_pass followed by / location / abc/ {proxy_pass http://klvchen.com/;} # will be represented as http://klvchen.com/test.html# case 2: after proxy_pass without / location / abc/ {proxy_pass http://klvchen.com;} # will be represented as http://klvchen.com/abc/test.html

Commonly used regularity

.: matches any character except the newline character

?: repeat 0 or 1 times

+: repeat 1 or more times

*: repeat 0 or more times

\ d: match the number

^: match the beginning of the string

$: the end of the matching string

{n}: repeat n times

{n,}: repeat n or more times

[C]: matches a single character c

[amurz]: matches any of the lowercase letters of amurz

The matching between parentheses () can be referenced later by $1, and $2 represents the content in the second () above. What is confusing in the rule is the escape of special characters.

The above is all the content of the article "sample Analysis of matching rules in nginx". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report