Secure Apache & Nginx MIME types with X-Content-Type-Options nosniff

X-Content-Type-Options Header Implementation in Apache, Nginx, IBM HTTP Server & Shared Hosting

Every resource served from a web server is associated with MIME type (also called content-type).

There is a possibility to execute style sheet and steal content from another site through content type doesn’t match. You may prevent this vulnerability in Internet Explorer or Google Chrome by adding nosniff in the header.

In this quick guide, I will explain how to add X-Content-Type-Options header in Apache HTTP, Nginx, IHS & Shared hosting to reduce MIME types attack risk.

Few things

Apache and IBM HTTP Server

LoadModule headers_module modules/mod_headers.so
Header set X-Content-Type-Options nosniff

Here is how the header response looks like.

x-content-type-results

Nginx Web Server

add_header X-Content-Type-Options nosniff;

Implementation in Shared Hosting

If you are using shared hosting like SiteGround or anyone who offers .htaccess file.

Header set X-Content-Type-Options nosniff

I hope this adds a layer of security to your site.

Enjoyed reading the article? How about sharing with the world?