H
H
hitakiri2015-02-11 18:13:26
Nginx
hitakiri, 2015-02-11 18:13:26

How to force Nginx to distribute zipped static?

Good time. Built nginx with http_gzip_static_module, nginx -V shows:

--with-http_ssl_module
 --with-http_realip_module
 --with-http_addition_module 
 --with-http_sub_module
 --with-http_dav_module
 --with-http_flv_module
 --with-http_mp4_module
 --with-http_gunzip_module
 --with-http_gzip_static_module
 --with-http_random_index_module
 --with-http_secure_link_module
 --with-http_stub_status_module
 --with-http_auth_request_module
 --with-mail --with-mail_ssl_module
 --with-file-aio --with-http_spdy_module
 --with-cc-opt='-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Wp,-D_FORTIFY_SOURCE=2' 
--with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed'
 --with-ipv6

Nginx config:
location / {
  gzip_static on;
        root   /var/www;
        index  index.html;
    }

The www folder contains the index.html.gz file. The server gives a 403 error. Everything works without compression. I tried to compress with the Grunt module and 7-zip, the result is the same.
Everything works on ubuntu 12.04.
Upd. I found the following: if the www folder contains an uncompressed index.html - no matter what is in it, now it is empty, then index.html.gz is returned normally. What is mysticism?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Leonid Sysoletin, 2015-02-11
@sysoletin

I strongly suspect that either it is necessary gzip_static always;, or the non-zip file should lie side by side.
By the way, are you sure that this is exactly what you need, and not compression "on the fly" of uncompressed static stored on disk? There's not much overhead is obtained.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question