NGINX and the Processing Priority of location Directives
In an NGINX domain configuration you can have several location directives whose settings overlap. Here is the order in which they are evaluated
Fortunately, the order in which the individual directives are evaluated is very simple and logical:
- = (exact match), e.g. location = /path
- ^~ (prefix match), e.g. location ^~ /path
- ~ (case-sensitive regular expression), e.g. location ~ /path/
- ~* (case-insensitive regular expression), e.g. location ~* .(jpg|png|bmp)
- /, e.g. location /path
A useful online tester is available here