The location block
We have established that Nginx offers you the possibility to fine-tune your configuration down to three levels—at the protocol level (http
block), the server level (server
block), and the requested URI level (location
block). Let us now detail the latter.
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:
location [=|~|~*|^~|@] pattern { ... }
The first optional argument is a symbol called location modifier ...
Get Nginx HTTP Server - Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.