• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

gzip not working in nginx?

Azurel

Silver Pleskian
In plesk panel 11.5.30 (with debian 6) I go to "Web Server settings" and add this line to nginx "gzip_proxied any;".

alternative, I tested this lines too:
gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

I go to http://www.gidnetwork.com/tools/gzip-test.php and enter my domain. Result is:
"Web page compressed?: No".

status HTTP/1.1 200 OK
server nginx
date Tue, 17 Dec 2013 14:43:11 GMT
content-type text/html;
charset=utf-8
connection close
x-powered-by PleskLin
cache-control no-transform

Can anybody help me here?


EDIT: I tried this too:

As root, create the file: /etc/nginx/conf.d/gzip.conf

Enter the following:

gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";

Then restart nginx in Plesk Services Management with: /etc/init.d/nginx restart
 
Last edited:
Just edit /etc/nginx/conf.d/gzip.conf file as root:

gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;
gzip_disable “msie6″;

Then run nginx -t to test the configuration and if that’s all ok, restart nginx by running /etc/init.d/nginx restart.
 
Thanks for your support. :)

@InderS
Thats my output:
/etc/nginx/nginx.conf said:
#user nginx;
worker_processes 1;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

client_max_body_size 20M;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;

#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;
}

@IgorG
I have added this file, see my "EDIT". I have added it again with your code.. nothing changed. :(
/etc/nginx/conf.d/gzip.conf said:
# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# /etc/init.d/nginx restart
Starting nginx: [ OK ]

nginx01.png
 
Last edited:
Explain: I had a DNS problem-with my router, so I can't look gzip in browser myself the last days.. now I have resolved the problem and see that chrome show me the page is now gzipped:
Cache-Control:no-transform
Connection:keep-alive
Content-Encoding:gzip
Content-Type:text/html; charset=utf-8
Date:Wed, 18 Dec 2013 13:37:23 GMT
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Powered-By:pleskLin

The page http://www.gidnetwork.com/tools/gzip-test.php shows wrong results!?

I have tested it with another page: http://checkgzipcompression.com and this have a correct result:
YES, it's GZIP enabled!

Uncompressed size: 35,550 bytes

Compressed size: 8,228 bytes


Thanks for your fast help!
 
Hello,

If you want to test your Gzip compression through curl command. You can use following command

Code:
curl --header "Accept-Encoding: gzip,deflate,sdch" -I http://domain.com


Thank you ..!
 
Just edit /etc/nginx/conf.d/gzip.conf file as root:

gzip on;
gzip_proxied any;
gzip_types text/plain text/xml text/css application/x-javascript;
gzip_vary on;
gzip_disable “msie6″;

Then run nginx -t to test the configuration and if that’s all ok, restart nginx by running /etc/init.d/nginx restart.

The Version above not gzip Javascript- or RSS-files. For all that interesst in this topic. That is little better:

gzip on;
gzip_proxied any;
gzip_types text/plain application/xml text/css text/js text/xml application/x-javascript text/javascript application/json application/xml+rss;
gzip_vary on;
gzip_disable "msie6";
 
When I stop the nginx service, the apache server correctly compresses the CSS and JS files!!! arrrgggg. took me too many hours to figure this out &^$%#$!

I have a JQuery file that is loaded on my server to check : http://checkgzipcompression.com/?url=http://www.bagtoss.com/jquery.js&reload=true

It now works. JS files are being compressed. So the question is now: is there a setting that I have wrong in my gzip.conf file??

This person posted that gzip is not working with nginx. https://forum.nginx.org/read.php?2,263778,263778#msg-263778


Here is the contents of /etc/nginx/conf.d/gzip.conf
gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types text/css text/plain application/x-javascript text/xml application/xml application/xml+rss application/javascript text/javascript image/x-icon image/bmp image/svg+xml application/x-httpd-php;
gzip_vary on;


Also, when run checking nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful


With nginx running, no matter what the settings are, I can't get CSS and JS to be compressed and served!

HTTP/1.1 200 OK
Server: nginx
Date: Fri, 29 Jan 2016 04:17:21 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 20
Connection: keep-alive
Set-Cookie: PHPSESSID=sfi0gkgqr87v3n5v96n3hcibr1; path=/
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, must-revalidate
Pragma: no-cache
Set-Cookie: language=en; expires=Sun, 28-Feb-2016 04:17:20 GMT; path=/; domain=www.bagtoss.com
Set-Cookie: currency=USD; expires=Sun, 28-Feb-2016 04:17:20 GMT; path=/; domain=www.bagtoss.com
Vary: Accept-Encoding
Content-Encoding: gzip
X-Powered-By: PleskLin


When I execute: cat /etc/nginx/nginx.conf

#user nginx;
worker_processes 1;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;


events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;

#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;
}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;
 
I just stumbled across this post on Google and thought I'd share my solution. Apache apparently uses the MIME-Type "application/javascript" but the suggested gzip.conf only uses "text/javascript".

gzip on;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript image/x-icon image/bmp image/svg+xml application/javascript;
gzip_vary on;
 
Back
Top