Turn off gzip for a location in Nginx
Posted
by
Nyxynyx
on Server Fault
See other posts from Server Fault
or by Nyxynyx
Published on 2012-10-14T18:00:22Z
Indexed on
2012/10/16
17:06 UTC
Read the original article
Hit count: 318
How can gzip be turned off for a particular location and all its sub-directories? My main site is at http://mydomain.com
and I want to turn gzip off for both http://mydomain.com/foo
and http://mydomain.com/foo/bar
. gzip
is turned on in nginx.conf
.
I tried turning off gzip
as shown below, but the Response Headers in Chrome's dev tools shows that Content-Encoding:gzip
.
How should gzip/output buffering be disabled properly?
Attempt:
server {
listen 80;
server_name www.mydomain.com mydomain.com;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /var/www/mydomain/public;
index index.php index.html;
location / {
gzip on;
try_files $uri $uri/ /index.php?$args ;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_read_timeout 300;
}
location /foo/ {
gzip off;
try_files $uri $uri/ /index.php?$args ;
}
}
© Server Fault or respective owner