扩展默认的nginx mime.types文件 [英] extending default nginx mime.types file

查看:823
本文介绍了扩展默认的nginx mime.types文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为nginx mime类型添加一些额外的类型,但是我不想编辑默认的/etc/nginx/mime.types,因为它会给部署过程增加一些额外的复杂性.

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.

如果我将 types {...} 部分添加到我的它将覆盖用include mime.types;声明的所有其他类型.

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.

推荐答案

如果我将类型{...}部分添加到我的nginx.conf中,它将覆盖所有 使用include mime.types;声明的其他类型.

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;.

不,不会.

您只需要在与mime.types include相同的级别上指定其他类型:

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;
}

这篇关于扩展默认的nginx mime.types文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆