Hello! On Sun, Nov 27, 2022 at 02:31:20AM +0800, Danila Vershinin wrote:
> Thank you for the answer. A more generic question follows: > > While we understand that IfIsEvil mostly applies to "being evil inside > location context."... > > We notice some directives allow being placed within "if in location" but > not within "if" in the server context. > > An example is gzip module's main directive: > http://nginx.org/en/docs/http/ngx_http_gzip_module.html#gzip > > Context: http, server, location, if in location > > So "gzip on" can be done in "if in location", but NGINX does not allow this > to be done in just "if" (which seems not an "evil" thing to do). > > Is there a specific rationale for why many NGINX directives are not allowed > in server-level "if" but are allowed in "if in location"? > > Consequentially, is there any problem in allowing server-level `if` context > for such directives by adding corresponding flags? > And is there are problem in doing the same for directives that doesn't > support any kind of "if" (neither `if` in server nor `if in location`), > like `gzip_proxied` directive? 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. For obvious reasons you can't just allow non-rewrite directives within server-level "if" blocks: you have to make them work somehow. Trying to do so will likely create even bigger issues than the current if-in-location problems. Summing the above: yes, there is a problem. -- Maxim Dounin http://mdounin.ru/ _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org