Is it possible for nginx to decompress FILES on-the-fly (not proxied)?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Is it possible for nginx to decompress FILES on-the-fly (not proxied)?

J.R.
I did a lot of googling and only came up with answers from many years
ago, or unanswered questions. Maybe I'm just not using the right
search keywords, so I figured I would ask the following....

Here's my scenario... I have a bunch of static html files that would
be served directly via nginx.

Is it possible to gzip them all, storing ONLY the compressed version
and have everything work as expected?

I've done some experimenting and I'm coming up short getting things to work...

I am using the following directives (skipping non-relevant), and yes
the extra modules were compiled in:

gzip on;
gzip_static on;
gunzip on;

If I make a request and allow compression, then it reads from the .gz
file no problem. If I make a request without allowing compression,
then I get a "file not found"...

I've tried with & without "try_files".  Also if I append something
like "$uri.gz" to try files, then it sends the compressed file as-is
(what should be decompressed on the client side is still compressed).

I would hate to have to add a wrapper script and complicate things
just to accommodate that 1% that might request the data
uncompressed...

From what I can gather reading over the gunzip source, it appears that
decompression is only for when it's proxying (decompress the upstream
response).

Even if there's a non-standard patch available, I have no issues
recompiling to get this to work.
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Is it possible for nginx to decompress FILES on-the-fly (not proxied)?

J.R.
Well, figured it out... I swear I tried this yesterday, but maybe I
didn't or my configuration was incomplete...

If you use "gzip_static always;" in combination with the below
statements, it works correctly! It sends the compressed response as
expected, and will decompress on-the-fly when necessary.

:)


> I am using the following directives (skipping non-relevant), and yes
> the extra modules were compiled in:
>
> gzip on;
> gzip_static on;
> gunzip on;
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx