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; 
} 
} 
0

user www-data; worker_processes 4; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf;

events {
        worker_connections 4096; ## max clients = worker_processes * worker_connections
        multi_accept       on;
        use                epoll;
}

http {
        ##
        # Basic Settings
        ##
        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        client_body_timeout 12;
        client_header_timeout 12;
        send_timeout 10;
        types_hash_max_size 2048;
        server_tokens off;

        proxy_buffering on;
        proxy_buffer_size 16k;
        proxy_buffers 64 4k;
        proxy_busy_buffers_size 24k;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;
        ## more tuning
        client_max_body_size 30M;
        client_body_buffer_size 12K;
        server_names_hash_max_size 1024;
        server_names_hash_bucket_size 112;

        client_header_buffer_size 2k;
        large_client_header_buffers 6 8k;

        ##
        # SSL Settings
        ##
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##
        #access_log     off;
        log_not_found  off;
        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;
        ##
        # Gzip Settings
        ##
        gzip  on;
        gzip_vary on;
        gzip_min_length 1000;
        gzip_comp_level 9;
        gzip_proxied expired no-cache no-store private auth;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
        gzip_disable "MSIE [1-6]\.";

        ##
        # Virtual Host Configs
        ##
        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;
}
1
  • Can you please explain what you've changed in this file and why? – Matt Apr 19 '20 at 23:31

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.