Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a bunch of gzipped log files I'd like to serve with nginx. I want them to 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
share|improve this question

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

share|improve this answer
One minor note: it's suggested that both files' modification times (mtime) are the same. – Alexander Azarov Mar 1 '11 at 18:09
And you can test it's working with curl --header "Accept-Encoding: gzip" -I your_url, and without the --header to check it still serves the uncompressed file if necessary. – Tom Sep 29 '15 at 12:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.