X-Content-Type-Options 导致图像显示为乱码文本 [nginx]
X-Content-Type-Options causes image to display as gibberish text [nginx]
我设置了反向代理端口 8086。端口 8086 是 运行 一个 javascript 随机显示 webp 格式的图像。如果我尝试访问该域,它会将图像显示为乱码文本。如果我访问 ip 地址而不是域,它工作正常。
我发现 more_set_headers "X-Content-Type-Options : nosniff"
导致图片显示为乱码。有没有办法只删除特定站点的设置?导致 X-Content-Type-Options : nosniff 设置为适用于所有站点。
nginx 配置文件
server {
server_name sub.example.com www.sub.example.com;
access_log /var/log/nginx/sub.example.com.access.log ;
error_log /var/log/nginx/sub.example.com.error.log;
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8086/img;
proxy_redirect off;
proxy_set_header X-Content-Type-Options "";
}
}
如何从特定站点删除 X-Content-Type-Options : nosniff?
这可以通过“功能性”方式完成:始终添加 header 和来自 map{} 的值。映射 $host $nosniff {myhost '';默认 nosniff;}
我设置了反向代理端口 8086。端口 8086 是 运行 一个 javascript 随机显示 webp 格式的图像。如果我尝试访问该域,它会将图像显示为乱码文本。如果我访问 ip 地址而不是域,它工作正常。
我发现 more_set_headers "X-Content-Type-Options : nosniff"
导致图片显示为乱码。有没有办法只删除特定站点的设置?导致 X-Content-Type-Options : nosniff 设置为适用于所有站点。
nginx 配置文件
server {
server_name sub.example.com www.sub.example.com;
access_log /var/log/nginx/sub.example.com.access.log ;
error_log /var/log/nginx/sub.example.com.error.log;
add_header X-Proxy-Cache $upstream_cache_status;
location / {
proxy_pass http://xxx.xxx.xxx.xxx:8086/img;
proxy_redirect off;
proxy_set_header X-Content-Type-Options "";
}
}
如何从特定站点删除 X-Content-Type-Options : nosniff?
这可以通过“功能性”方式完成:始终添加 header 和来自 map{} 的值。映射 $host $nosniff {myhost '';默认 nosniff;}