我有一台带有 nginx 的服务器。而且我有很多图像 - pngs 和 jpgs 保存为没有扩展名的文件(如“123123123_321312”)。
当我在 html 页面中使用标签“img”时,我会在控制台中收到这些消息:
资源解释为图像,但使用 MIME 类型 application/octet-stream: "http://xxxx/images/1350808948_997628"传输。 jquery.js:2
资源解释为图像,但使用 MIME 类型 application/octet-stream: "http://xxxx/images/1343808569_937350"传输。
有没有办法让 nginx 添加具有请求文件的正确 mimetype 的 header ?
最佳答案
您应该使用 default_type
指令:
server {
...
default_type text/html;
location /images/png {
default_type image/png;
}
location /images/jpg {
default_type image/jpeg;
}
}
关于nginx - 如何在 NGINX 配置中指定没有扩展名的文件的 mimetype?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13509050/