[nginx_gzip_static] Necessity to create empty file with always option.

Richard Fussenegger richard at fussenegger.info
Tue Nov 17 18:15:43 UTC 2015


Hi guys!

I have the following weird situation: Several files with .gz extension
are on disk and I have a location were requests are processed that do
not include it, so I set the option gzip_static to always and also
installed the gunzip module. The problem is, I still need to create
EMPTY files without the .gz extension on disk for everything to work as
expected. Expected is that gunzip extracts the archives if no GZIP
support is announced by the client and nginx directly streams the
response if the client did.

The configuration is fairly easy:

    location /var/files {
        internal;

        gunzip on;
        gzip_proxied any;
        gzip_static always;

        aio on;
        sendfile off;
        tcp_nodelay on;
        tcp_nopush off;

        try_files $uri =404;
    }

    location / {
        location ~ '^/[a-z0-9]{40}\.[a-z0-9-\.]+$' {
            include php.ngx;
            try_files /validate-token.php =404;
        }

        return 444;
    }

The PHP logic is simple:

    <?php

    // Code ...

    if ($valid) {
        header("X-Accel-Redirect: /var/files/{$filename}");
        // Code ...
    }
    else {
        // Code ...

My question is now, is this some kind of bug, misconfiguration, or a
feature and I am not getting how to use it properly?

Kind regards
Richard



More information about the nginx-devel mailing list