Is it possible for nginx to decompress FILES on-the-fly (not proxied)?
themadbeaker at gmail.com
Sat Feb 29 14:44:54 UTC 2020
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:
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
>From what I can gather reading over the gunzip source, it appears that
decompression is only for when it's proxying (decompress the upstream
Even if there's a non-standard patch available, I have no issues
recompiling to get this to work.
More information about the nginx