You may already have understood this, but I came across this question when I was struggling with the conversion of Apache to Nginx.
Nginx has a gzip_static module that automatically searches for pre-compressed versions of files and maintains them if the client supports gzip. To do this, move the files from the Compressed directory to the Data directory and slightly change the file extensions:
Before:
# cd MyProject
After:
In your Nginx configuration:
location /path/to/MyProject/Data { gzip_static on; }
Note that Nginx must be built with --with-http_gzip_static_module. You can check if your version already has this:
nginx -V
The only drawback is that you need to move / rename files, but this is a slight inconvenience for a single-layer solution.
Here's how to move / rename gzip files as expected by nginx:
cd Data mv ../Compressed/*gz ./ rename 's/(.*)gz$/$1.gz/' *gz
source share