Home > database >  Can I put the upstream directive inside server context?
Can I put the upstream directive inside server context?

Time:09-22

The [upstream][1] directive in ngx_http_upstream_module is supposed to be in the http context.

However, I'll have more than one server inside the http context, and I would like to have multiple upstream with the same name but different servers inside.

Could I put the upstream directive inside the server context to not conflict with the names? In other words, can we have lexical scope in the configuration?

CodePudding user response:

No, you can't.

If you try, you'll get:

nginx: [emerg] "upstream" directive is not allowed here in ...

You'll have to give it another name.

  • Related