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

查看:10305
本文介绍了强制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;
}

我还没有找到确切的字符串应用程序/ xml 在我的 mime.types 中,所以我想你可以直接把它包含在你的服务器块,服务器范围内等等。

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天全站免登陆