I have setup to reverse proxy port 8086. Port 8086 is running a javascript that display random a image in webp format. If I try to visit the domain it displays the image as gibberish text. It works fine if I visit the ip address but not the domain.
I have out that more_set_headers "X-Content-Type-Options : nosniff"
is causing the image to display as gibberish text. Is there a way to remove that setting for a specific site only? cause X-Content-Type-Options : nosniff is set to apply to all sites.
nginx conf
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 "";
}
}
How to remove X-Content-Type-Options : nosniff from specific site?
CodePudding user response:
This can be done in a "functional" way: always add the header with a value from map{}. Map $host $nosniff {myhost ''; default nosniff;}