Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

extending default nginx mime.types file

I'd like to add a few extra types to nginx mime types, but I don't want to edit the default /etc/nginx/mime.types as it would add some extra complexity to the deployment process.

If I add a types {...} section to my nginx.conf it will override all the other types that were declared with the include mime.types;.

I've thought that I could write a location rule for the extensions of the files that I need to handle, but I suppose that there must be a cleaner way to achieve this.

like image 801
fortran Avatar asked May 28 '13 10:05

fortran


People also ask

What is the extension of MIME file?

MIME files are more commonly seen using a . MIM extension.

What is MIME type in nginx?

The default mime. types file from nginx only contains MIME types for more or less common file extensions. And it certainly isn't very common to have json static files. Also, what types should be gzipped? You may include MIME types for all well compressible content that you have on your site.

How do I change the MIME type of a file?

In the Connections pane, go to the site, application, or directory for which you want to add a MIME type. In the Home pane, double-click MIME Types. In the MIME Types pane, click Add... in the Actions pane. In the Add MIME Type dialog box, add the file name extension and MIME type, and then click OK.

What is the default nginx config file?

By default, the configuration file is named nginx. conf and placed in the directory /usr/local/nginx/conf , /etc/nginx , or /usr/local/etc/nginx .


1 Answers

If I add a types {...} section to my nginx.conf it will override all the other types that were declared with the include mime.types;.

No, it won't.

You just need to specify additional types on the same level as your mime.types include:

include mime.types; types {     # here are additional types     application/javascript mjs; } 
like image 70
VBart Avatar answered Sep 20 '22 11:09

VBart