Tag Archives: nginx

Understanding Nginx location rules

Ningx is slim and the configuration feels in many respects less bloated than Apache. But it’s also a little idiosyncratic, and the official documentation, still, is not great. I keep forgetting about the location rules, so here’s an attempt to make my own cheatsheet.

A location block applies some configuraton by matching against a request URI. A location can be one of these five types:

 nginx

(The official documentation, among other things, calls “prefix” the type identifier string ( =,^*,~,~*); this can be confusing, because we are also speaking (in cases 2.a 2.b) of “prefix matching” …)

Important: among the list of location blocks inside a server, only one will be picked (or none). The only way to “compose” settings is by using nested locations.