网站目录有一些 txt/log/inf/ini 文件,并使用了 cf

尝试添加 header 让 这些文件强制在浏览器打开而不是下载

add_header 'Content-Type' 'text/plain; charset=utf-8';

结果 cf 没有透传, Content-Type header 丢的一干二净,看到 cf 自己添加了一个 header

x-content-type-options: nosniff

不知道是不是这个原因屏蔽了 MIME 类型嗅探

尝试换了个方法解决了

nginx server 段 或者 location 段添加如下内容

types { # 可以把多个后缀名写在一行,也可以单独每行写 text/plain txt ini inf log logs vbe; text/plain ini; text/plain inf; text/plain log; text/plain css; text/plain js; }

如果要将所有后缀类型强制以明文方式在线打开,试了下是不支持 通配符 *,要换个方法

default_type text/plain; charset utf-8;
最后修改:2023 年 04 月 24 日
如果觉得我的文章对你有用,请随意赞赏