Welcome! Log In Create A New Profile

Advanced

Re: Disable gzip inside an IF statement?

Maxim Dounin
June 29, 2009 07:28AM
Hello!

On Fri, Jun 26, 2009 at 03:44:52PM -0400, cx wrote:

> I need to conditionally enable gzip, based on a variable.
>
> When I try to use an "if" statement, it doesn't work, nginx complains I can't use "gzip" inside of "if".
>
> Looking at the manual, I see gzip has the following context allowed:
>
> "context: http, server, location, if (x) location"
>
> What does "if (x) location" mean? I couldn't find an example.

It means bad translation. Original docs say "if inside location"
(in Russian). So something like this will work (but beware, orges
- as usual with if's):

server {
...

location / {
if (...) {
gzip off;
break;
}
...
}

}

But this will complain:

server {
...

if (...) {
gzip off;
}

...
}

Maxim Dounin

> Alternatively, if someone can suggest a way to disable gzip dynamically from within PHP, that would be great. It's possible to do this in Apache:
>
> <?php apache_setenv("no-gzip","1"); ?>
>
> But obviously that function isn't supported in nginx.
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,3455,3455#msg-3455
>
>
Subject Author Posted

Disable gzip inside an IF statement?

cx June 26, 2009 03:44PM

Re: Disable gzip inside an IF statement?

Maxim Dounin June 29, 2009 07:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 216
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready