How can I define a mime type in nginx for tar.bz2 or tar.gz files?

Solution 1:

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.

Solution 2:

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.