Nginx Location Match Rules

Created On: 2014-06-10

Location is used in nginx config file to map a request URI to a config block.

Brief listing of different type of matches:

Priority from highest to lowest is

  1. = match
  2. longest prefix match using the ^~ operator
  3. in the order the config file is written, the first regexp match
  4. longest prefix match

Official document is in nginx location syntax, but I often find it confusing.

Is this post helpful?