How can I add “X-Content-Type-Options: nosniff” to all the response headers from my web server

浪子不回头ぞ 提交于 2019-12-23 04:52:23

问题


I am running an apache web server. I would like to add "X-Content-Type-Options: nosniff" to all the response headers going from my web server. How can I do that? Is it possible to make changes to apache config files to accomplish this?


回答1:


Just append this to your webserver configuration, after making sure mod_headers is loaded:

<Directory "your_web_server_documents_directory">
    .......
    Header always set X-Content-Type-Options nosniff
    .......
</Directory>



回答2:


what i did is this. i place the tags right after commented out property modules/mod_headers.so and restart my appserver but still the same response header.

LoadModule headers_module modules/mod_headers.so

<Directory mod_headers.c>
     Header always set X-Content-Type-Options nosniff
</Directory>


来源:https://stackoverflow.com/questions/21322295/how-can-i-add-x-content-type-options-nosniff-to-all-the-response-headers-from

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!