nginx - 强制 nginx 发送特定的 Content-Type

标签 nginx http-headers content-type

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

Content-Type: application/octet-stream;

我希望它是

Content-Type: application/xml;

我尝试过类似的方法

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

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

但没有任何效果。

最佳答案

如果您没有文件扩展名:

location ~ something {
   default_type application/xml;
}

Nginx docs for default_type

如果您正在设置让我们使用创建 http 服务器的客户端加密证书: How to use golang lego let's encrypt client behind nginx?

关于nginx - 强制 nginx 发送特定的 Content-Type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19629930/

相关文章:

php - 从 php 服务器重新启动我的 Nodejs 应用程序(使用 pm2)

safari - HTTP_X_PURPOSE的定义是什么?

php - 未使用 Referrer-Policy 设置 header

php - 如何在cakephp中写内容类型?

html - 为什么我需要在这个 Java Servlet 中将内容类型设置为 html?

nginx - 如何在 Play Framework 2 中获取用户的 IP?

nginx - 什么是kube-nginx,它与kube-proxy有何区别?

nginx - Nginx 中不同 IP 上的不同域?

PHP - 将 Nginx 与 php-fpm 结合使用时获取自定义 header

ms-word - 如何提供 .RTF