nginx nested locations

It was unintuitive and the nginx doc doesn’t put it clearly,

for nested blocks, for example

    location /protected {
      access_by_lua_block {
        local opts = {
          redirect_uri = "/auth_redirect",
          use_nonce = true
      default_type text/html;
      content_by_lua 'ngx.say("<p>Protected</p>")';

      location /protected/api {

      location /auth {

the URL, http://{hostname}/protected/auth wont work

while at the same time, the URL http://{hostname}/protected/api would direct correctly.

as the nested location is still following the same pattern or prefix matching, without any url concatenation.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s