I tried adding these lines to mime.types:

application/x-gtar tar.gz tgz tar.bz2 tbz2 tbz;
application/x-bzip2 bz2;
application/x-gzip  gz;

But nginx reports "Content-Type: application/x-bzip2" for a tar.bz2 file. How can I fix it?

Additional question: what's the correct mime type for tar.bz2/tbz2 files? Different sources gave me all kinds of different answers: application/x-gtar, application/x-compressed-tar, application/x-bzip-compressed-tar, application/x-tar-bz2, application/x-bzip2, etc. Same for tar.gz/tgz


There's a disclaimer in /etc/mime.types file:

Note: Compression schemes like "gzip", "bzip", and "compress" are not actually "mime-types". They are "encodings" and hence must not have entries in this file to map their extensions. The "mime-type" of an encoded file refers to the type of data that has been encoded, not the type of encoding.

This means that you should have application/x-tar to map tarballs instead of separate content-type for each compressing method.

You can safely copy it from /etc/mime.types for instance.

  • I don't have that note in /etc/mime.types, but I can see some logic in it. So that means *.tar.gz & co should probably be identified as application/x-tar. Still, that leaves 2 questions: 1. How to define the mime type in nginx? (Not all gz's are tars) and 2. What's the mime type of foo.gz? Is it necessary to extract the file to determine it? – aditsu Jul 24 '13 at 8:43
  • @aditsu did you find an answer to this? – CMCDragonkai Apr 16 '14 at 12:32
  • @CMCDragonkai not really, I just used application/x-bzip2 bz2; and application/x-gzip gz; – aditsu Apr 16 '14 at 13:43

You probably can use the HttpHeadersMoreModule with some regular expression matching to override the Content-Type if the url ends with one of the extensions.

  • Hmm, I haven't tried it yet, and seems convoluted, but I guess it could work. – aditsu Jul 24 '13 at 8:52

According to the conf/mime.types, it seems that nginx doesn't support this mime types.

  • 2
    That's why I'm trying to add them. But apparently it doesn't support dotted extensions. – aditsu Aug 24 '11 at 3:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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