扩展默认的 nginx mime.types 文件 [英] extending default nginx mime.types file
问题描述
我想为 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 {...}
部分添加到我的 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;
.
我想我可以为我需要处理的文件的扩展名编写一个位置规则,但我认为必须有一种更简洁的方法来实现这一点.
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 添加一个 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;.
不,不会.
您只需要在与您的 mime.types
相同的级别上指定其他类型,包括:
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屋!