How do I serve pre-gzipped files with nginx so that they'll be shown as text in the browser?

I have a bunch of gzipped log files I'd like to serve with nginx. I want them to be served in such a way that they're automatically inflated by the browser. I assume that means I need nginx to send the files as .gz with a text/plain header. This can be done in apache with something like:

<FilesMatch *.gz>
    ForceType text/plain
</FilesMatch>

Solution 1:

You need the HttpGzipStatic module for this. Put gzip_static on; in your config and create your .gz files. You will need to keep both the zipped and the original file, you can then request, for example, /css.css and be served the zipped /css.css.gz