Nginx dows't serve compressed static .html files. is it a bug?

In my previous post I explained what tried and didn’t manage to it. I
attached nginx.conf file. I’ll
be very grateful is somebody show me a successful way to do this.

On Wed, Feb 04, 2015 at 11:36:04PM +0200, peter petrov wrote:

In my previous post I explained what tried and didn’t manage to it. I
attached nginx.conf file. I’ll
be very grateful is somebody show me a successful way to do this.

http://nginx.org/r/gzip_static

gzip_static on;

curl -i --compressed http://localhost/file.html

will get file.html.gz if it exists, with “Content-Encoding: gzip”;
or file.html if that exists, or 404.

Check the “bytes sent” field in your access_log to see which was
sent. Omit the “–compressed” in the curl command to see the difference.


Francis D. [email protected]

-------- ??? ??? --------

???: Francis D. [email protected]

???: Re: nginx dows’t serve compressed static .html files. is
it a bug?

???: [email protected]

??? ???: 05.02.2015 00:53

On Wed, Feb 04, 2015 at 11:36:04PM +0200, peter petrov wrote:

In my previous post I explained what tried and didn’t manage to it. I

attached nginx.conf file. I’ll

be very grateful is somebody show me a successful way to do this.

Module ngx_http_gzip_static_module

gzip_static on;

curl -i --compressed http://localhost/file.html

will get file.html.gz if it exists, with “Content-Encoding: gzip”;

or file.html if that exists, or 404.

Check the “bytes sent” field in your access_log to see which was

sent. Omit the “–compressed” in the curl command to see the difference.

Francis D. [email protected]


nginx mailing list

[email protected]

nginx Info Page

hi again ,
Thanks for your help
Francis D. I did what you suggested but it doesn’t work. Access.log
says both times with --compressed or without it “200 162” for the nginx
welcome screen.It is very weird.

On Thu, Feb 05, 2015 at 10:28:33PM +0200, peter petrov wrote:

Hi there,

Francis D. I did what you suggested but it doesn’t work. Access.log says both
times with --compressed or without it “200 162” for the nginx welcome screen.It is
very weird.

It works for me:

ls -l html/index.html*

-rw-r–r-- 1 root root 612 Jul 23 2013 html/index.html
-rw-r–r-- 1 root root 392 Feb 5 21:06 html/index.html.gz

cat conf/nginx.conf

events {}
http {
gzip_static on;
server {
listen 8080;
}
}

curl -i http://localhost:8080/

[http 200, I see the content]

curl -i --compressed http://localhost:8080/

[http 200, I see the content]

tail -n 2 logs/access.log

127.0.0.1 - - [05/Feb/2015:21:08:51 +0000] “GET / HTTP/1.1” 200 612 “-”
“curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b
zlib/1.2.3 libidn/0.6.5”
127.0.0.1 - - [05/Feb/2015:21:08:57 +0000] “GET / HTTP/1.1” 200 392 “-”
“curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b
zlib/1.2.3 libidn/0.6.5”

Repeat the test with exactly this configuration to see if it fails for
you.

Or show exactly what you are doing so someone can see if it work for
them.

Good luck with it,

f

Francis D. [email protected]

-------- ??? ??? --------

???: Francis D. [email protected]

???: Re: nginx does’t serve compressed static .html files. is
it a bug?

???: [email protected]

??? ???: 05.02.2015 23:14

On Thu, Feb 05, 2015 at 10:28:33PM +0200, peter petrov wrote:

Hi there,

Francis D. I did what you suggested but it doesn’t work. Access.log says both
times with --compressed or without it “200 162” for the nginx welcome screen.It is
very weird.

It works for me:

ls -l html/index.html*

-rw-r–r-- 1 root root 612 Jul 23 2013 html/index.html

-rw-r–r-- 1 root root 392 Feb 5 21:06 html/index.html.gz

cat conf/nginx.conf

events {}

http {

gzip_static on;

server {

listen 8080;

}

}

curl -i http://localhost:8080/

[http 200, I see the content]

curl -i --compressed http://localhost:8080/

[http 200, I see the content]

tail -n 2 logs/access.log

127.0.0.1 - - [05/Feb/2015:21:08:51 +0000] “GET / HTTP/1.1” 200 612 “-”
“curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b
zlib/1.2.3 libidn/0.6.5”

127.0.0.1 - - [05/Feb/2015:21:08:57 +0000] “GET / HTTP/1.1” 200 392 “-”
“curl/7.15.5 (i386-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b
zlib/1.2.3 libidn/0.6.5”

Repeat the test with exactly this configuration to see if it fails for
you.

Or show exactly what you are doing so someone can see if it work for
them.

Good luck with it,

Francis D. [email protected]

Hi ,

Thank you for your efforts and patience. Things are getting better here
and I almost achieve your result
Nginx
serves static files now., but writes smth above “Welcome to nginx!”
index.html 00006440000… some numbers and finishes with Oustar
rootroot.

  1. sudo tar czvf index.html.gz index.html
    2.sudo curl -i --compressed
    http://localhost:8080/

or sudo curl -i http://localhost:8080/

they both produce the same result index.html000064400000…
3. sudo tail -n 2 logs/access.log makes the same result “200 483”
480B was the best I could achieve
using both tar and gzip -9 how did manage to get 392B out of 612B?


nginx mailing list

[email protected]

nginx Info Page

-------- ??? ??? --------

???: Francis D. [email protected]

???: Re: nginx does’t serve compressed static .html files. is
it a bug?

???: [email protected]

??? ???: 07.02.2015 00:53

On Fri, Feb 06, 2015 at 11:22:22PM +0200, peter petrov wrote:

Hi there,

ls -l html/index.html*

-rw-r–r-- 1 root root 612 Jul 23 2013 html/index.html

-rw-r–r-- 1 root root 392 Feb 5 21:06 html/index.html.gz

  1. sudo tar czvf index.html.gz index.html

Don’t use tar.

Just use gzip.

gzip index.html

or

gzip -c index.html > index.html.gz

f

Francis D. [email protected]

Hi,

Everything is working perfectly now. You can’t imagine how grateful am
I.


nginx mailing list

[email protected]

nginx Info Page

On Fri, Feb 06, 2015 at 11:22:22PM +0200, peter petrov wrote:

Hi there,

ls -l html/index.html*

-rw-r–r-- 1 root root 612 Jul 23 2013 html/index.html
-rw-r–r-- 1 root root 392 Feb 5 21:06 html/index.html.gz

  1. sudo tar czvf index.html.gz index.html

Don’t use tar.

Just use gzip.

gzip index.html

or

gzip -c index.html > index.html.gz

f

Francis D. [email protected]

peter petrov Wrote:

Everything is working perfectly now. You can’t imagine how grateful am

http://nginx.org/en/donation.html

:slight_smile:

Posted at Nginx Forum: