Contact us
Servers 1 min read · 11/2020

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:

  1. = (exact match), e.g. location = /path
  2. ^~ (prefix match), e.g. location ^~ /path
  3. ~ (case-sensitive regular expression), e.g. location ~ /path/
  4. ~* (case-insensitive regular expression), e.g. location ~* .(jpg|png|bmp)
  5. /, e.g. location /path

A useful online tester is available here

Share
LinkedIn Facebook

Need more than an article?

Get in touch with no obligation – a few sentences about what you are dealing with are enough.

Read on

Similar articles

More notes from operations and development.

All advice