1

· gzip shows as not enabled on my site

· and not even the tech support of my host, asmallorange, can figure out the cause of my problem

· hopefully someone here can

· i've documented my exact set-up (nothing more than this was done)

1) i installed centos 7 minimal

2) i logged in via putty

3) then i input the following commands

3a) yum update

3b) yum clean all

3c) yum install epel-release

3d) yum install nginx

3e) systemctl enable nginx

3f) vi /etc/nginx/nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    server_tokens       off;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    limit_conn_zone     $binary_remote_addr zone=addr:8m;
    limit_req_zone      $binary_remote_addr zone=mylimit:16m rate=16r/s;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  abcj.me;
        root         /srv;
        index        index-l1.html

        gzip            on;
        gzip_vary       on;
        gzip_min_length 1024;
        gzip_types      text/css text/plain;

        client_body_timeout 8;
        client_header_timeout 8;

        location ~*  \.(css|ico|jpeg|jpg|js|mp3|mp4|pdf|png|txt|webp|zip)$ {
            expires 16d;
        }

        location ~*  \.(html)$ {
            expires 1d;
        }

        error_page 404 /404-l1.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

    server {
        listen 80;
        server_name www.abcj.me;
        return 301 http://abcj.me$request_uri;
    }
}

3g) service nginx restart

4) i uploaded index-l1.html to srv via winscp

· nginx -V 2>&1 | tr -- - '\n' | grep module

· shows that i have

·· http_gzip_static_module

·· http_gunzip_module

· curl -H "Accept-Encoding: gzip" -I http://abcj.me/index-l1.html

·· does not show gzip acceptance

· https://www.giftofspeed.com/gzip-test/

·· does not show gzip acceptance

0

· the gzip commands need to be directly in the http block, not in the server block

user nginx; 
worker_processes auto; 
error_log /var/log/nginx/error.log; 
pid /run/nginx.pid; 

events { 
worker_connections 1024; 
} 

http { 
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; 
tcp_nodelay on; 
keepalive_timeout 65; 
types_hash_max_size 2048; 

server_tokens off; 

include /etc/nginx/mime.types; 
default_type application/octet-stream; 

limit_conn_zone $binary_remote_addr zone=addr:8m; 
limit_req_zone $binary_remote_addr zone=mylimit:16m rate=16r/s; 

gzip on; 
gzip_vary on; 
gzip_min_length 1024; 
gzip_types text/css text/plain; 

server { 
listen 80 default_server; 
listen [::]:80 default_server; 
server_name abcj.me; 
root /srv; 
index index-l1.html 

client_body_timeout 8; 
client_header_timeout 8; 

location ~* \.(css|ico|jpeg|jpg|js|mp3|mp4|pdf|png|txt|webp|zip)$ { 
expires 16d; 
} 

location ~* \.(html)$ { 
expires 1d; 
} 

error_page 404 /404-l1.html; 
location = /40x.html { 
} 

error_page 500 502 503 504 /50x.html; 
location = /50x.html { 
} 
} 

server { 
listen 80; 
server_name www.abcj.me; 
return 301 http://abcj.me$request_uri; 
} 
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.