This article is a mirror article of machine translation, please click here to jump to the original article.

View: 3078|Reply: 0

[Web] Introduction to Nginx location configuration priority

[Copy link]
Posted on 11/5/2023 9:10:18 PM | | |
location expression type

~ indicates that a regular match is performed, case sensitive
~* indicates that a regular match is performed, case insensitive
^~ indicates a normal character match. Use prefix matching. If the match is successful, no other locations are matched.
= Perform exact matching of normal characters. That is, an exact match.
@ "@" defines a named location when used when oriented internally, such as error_page, try_files

location priority description

The order of location in nginx and the location in the configuration is not very related. It has to do with the type of location expression. For expressions of the same type, the long string will be matched first.
Here's a breakdown by priority:
First priority: The equal sign type (=) has the highest priority. Once a match is successful, no more matches are looked.
Second priority: ^~ type expression. Once a match is successful, no more matches are looked.
Third priority: The priority of the regular expression type (~ ~*) is secondary. If there are multiple locations that can match, use the one with the longest regex.
Fourth priority: regular string match type. Match by prefix.

#顺序不等于优先级
(location =) > (location full path) > (location ^~ path) > (location ~,~* regular order) > (location partial start path) > (/)

location priority example

The configuration items are as follows:


Request match example


Original:The hyperlink login is visible.




Previous:OpenWRT settings to boot up the execution command
Next:ASP.NET Core (26) Interface (Minimal APIs) Minimal APIs
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com