Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
637 views
in Technique[技术] by (71.8m points)

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...