try_files and gzip_static

DonaldCock nginx-forum at
Mon Jul 17 21:26:40 UTC 2017

>From my knowledge, try_files works with gzip_static if both compressed and
uncompressed files exist, but with "gunzip on;", it doesn't seem like
try_files becomes aware of this, and so it'll only serve either the
compressed or uncompressed file.

Any idea how to get around this? I can't serve the files directly as there's
no file extension in the uri, and it's rewritten.

My config for that block:

location ~ ^/view/c1/(\w+)/(\d+)(/|\.html)?$ {
    gzip_static on;
    gunzip on;

    add_header Cache-Control "public, must-revalidate";
    try_files /static/b_$1/$2.html /view.php?b=$1&t=$2;

Posted at Nginx Forum:,275539,275539#msg-275539

More information about the nginx mailing list