Cover by Clement Nedelcu

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

O'Reilly logo

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), at the server level (server block), and at 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 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required