serve precompressed files without also serving their uncompressed counterparts

Valentin V. Bartenev vbart at nginx.com
Tue Dec 22 16:05:18 UTC 2015


On Tuesday 22 December 2015 11:01:19 snieuwen wrote:
> Hi,
> 
> Is it possible to serve precompressed files without serving their
> uncompressed counterparts?
> 
> For example:
> /var/www/ contains index.html.gz, but no index.html. How do I configure
> nginx to respond with index.html.gz when the client supports gzip or let
> nginx decompress the file on the fly when the client does not support gzip?
> 
> Based on this answer on stackoverflow http://serverfault.com/a/611757, I am
> currently using the following configuration:
> 
> location / {
>     try_files $uri $uri/ @application;
>     root /var/www;
>     gzip_static on;
>     gunzip on;
> }
> 
> @application configures the application server.
> When I try get the index.html page, nginx return a 403 forbidden error.
> 
[..]

  gzip_static always;

See the documentation: nginx.org/r/gzip_static

  wbr, Valentin V. Bartenev



More information about the nginx mailing list