Location - Nginx
Priority / Flow
- Test the URI against all prefix strings.
- If the exact match
=is found, the search stops. - If the
^~(caret-tilde) modifier prepends the longest matching prefix string, the regular expressions are not checked. - Store the longest matching prefix string.
- Test the URI against regular expressions.
- Stop processing when the first matching regular expression is found and use the corresponding location.
- If no regular expression matches, use the location corresponding to the stored prefix string.
Named location
- Named locations preserve
$urias it was - Can be reached only via
error_page,try_files
location @named_location {
# ...
}
Ref: Nginx FAQ
Ref: ngx_http_core_module
internal location
location ... {
internal;
}
internalonly can be accessed from internal requests- return error status
404if that is external requests
Internal request / Internal redirect
Internal requests are requests by:
rewritedirectiveerror_page,index,random_index, andtry_filesdirectivesX-Accel-Redirectresponse header field from an upstream server- “include virtual” command of the
ngx_http_ssi_modulemodule, by thengx_http_addition_modulemodule directives, and byauth_requestandmirrordirectives;