In the Nginx documentation, context for some directives (error_page directive for example) is given as follows:

Context: http, server, location, if in location

My question is, what does "if in location" context mean? I've been googling but couldn't find a proper explanation.

1 Answer 1


There are two distinct contexts for an if block, server and location.

The behaviour in these two contexts are quite different.


server {
    if (...) { ... }

    location ... {
        if (...) { ### }

The first if block is in server context. The second if block is in location context.

The context if in location specifies directives that may appear within the ### section in the above example.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .