强制 nginx 发送特定的 Content-Type [英] Force nginx to send specific Content-Type

查看:71
本文介绍了强制 nginx 发送特定的 Content-Type的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何覆盖 nginx 中的默认 Content-Type?目前,当我请求 01.dae 文件时,有

How to overwrite default Content-Type in nginx? Currently when I request 01.dae file, there's

Content-Type: application/octet-stream;

我希望它是

Content-Type: application/xml;

我尝试过类似

location ~* .dae$ {
  types { };
  default_type application/xml;
}

location ~* .dae$ {
  add_header Content-Type application/xml;
}

但没有任何效果.

推荐答案

可以编辑/etc/nginx/mime.types并添加

types {
    application/xml        dae;
}

我没有在我的 mime.types 中找到确切的字符串 application/xml 所以我想你可以直接将它包含在你的服务器块中,在服务器中范围什么的.

I haven't found the the exact string application/xml in my mime.types so I suppose you can directly include it inside your server block, in the server scope or something.

这篇关于强制 nginx 发送特定的 Content-Type的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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