Location is an instruction under the server block under the HTTP block in the Nginx configuration file, and the syntax structure is:
Location [= | ~ | ~* | ^~] URI {...}
[] The inner part is optional, and four identifiers can only be selected to specify how the request string and URI are matched.
If you do not add an optional part, Nginx will first match the request path to all location with the standard URI in order, and then match the location with the regular URI, if there is a regular URI match succeeds then use that location, if there is no regular URI match succeeds, use the A location with the highest match in the standard URI.
"=", strict matching pattern , before the standard URI , requires the request string to match the standard URI Strictly, if successful, immediate processing;
"^~", ignoring the regular URI pattern, before the standard URI, if the request string and the standard URI match the highest, immediately processing;
"~" means that the URI contains a regular expression, which is case-sensitive;
"~*", indicates that the URI contains a regular expression and is not case-sensitive.
The content is referenced from the Nginx high performance Web server and the Nginx official document.
Http.server.location instruction syntax in Nginx