Understanding and exploring the location block
We have established that NGINX lets you fine-tune your configuration down to three levels—at the protocol level (the http
block), the server level (the server
block), and the requested URI level (the location
block). Let’s now go into more detail about the third one.
Location modifier
NGINX allows you to define location
blocks by specifying a pattern that will be matched against the requested document URI:
server { server_name website.com; location /admin/ { # The configuration you place here only applies to # http://website.com/admin/ } }
Instead of a simple folder name, you can indeed insert complex patterns. The syntax of the location
block is shown here:
location [=|~|~*|^~|@] pattern { … }
The first optional argument is a symbol called location
that will define the way NGINX matches...