'In the server context, only rewrite directives are allowed
inside "if", and "if" works as it should: just provides an
conditional operator within the rewrite module instructions, and
does not try to create an implicit location configuration.'
https://mailman.nginx.org/archives/list/nginx-devel@nginx.org/thread/QEXJP4XQIUXB2QFU74AWXJI7FRXS5CLA/