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

Take a backup of an existing configuration file to restore if something goes wrong. To verify the header response, you may use the HTTP Header Checker online tool. If you are using cloud-based Security Protection like SUCURI, then you don’t have to worry, as this is already enabled by default.

Apache and IBM HTTP Server

Modify the httpd.conf file and ensure mod_headers.so is enabled. The following line should be uncommented.

Add following parameter

Save the configuration file and restart Apache to take effects.

Here is how the header response looks like.

Nginx Web Server

Add the following parameter in nginx.conf under server block

Save the nginx.conf file and restart Nginx to see the results.

Implementation in Shared Hosting

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

Login to your cPanel and go to File Manager Modify .htaccess file and add the following

Save the file and refresh the page to see the results.

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

Secure Apache   Nginx MIME types with X Content Type Options nosniff - 1Secure Apache   Nginx MIME types with X Content Type Options nosniff - 40Secure Apache   Nginx MIME types with X Content Type Options nosniff - 87Secure Apache   Nginx MIME types with X Content Type Options nosniff - 6Secure Apache   Nginx MIME types with X Content Type Options nosniff - 29Secure Apache   Nginx MIME types with X Content Type Options nosniff - 6Secure Apache   Nginx MIME types with X Content Type Options nosniff - 64Secure Apache   Nginx MIME types with X Content Type Options nosniff - 24Secure Apache   Nginx MIME types with X Content Type Options nosniff - 73Secure Apache   Nginx MIME types with X Content Type Options nosniff - 70Secure Apache   Nginx MIME types with X Content Type Options nosniff - 91Secure Apache   Nginx MIME types with X Content Type Options nosniff - 47Secure Apache   Nginx MIME types with X Content Type Options nosniff - 89Secure Apache   Nginx MIME types with X Content Type Options nosniff - 44Secure Apache   Nginx MIME types with X Content Type Options nosniff - 57Secure Apache   Nginx MIME types with X Content Type Options nosniff - 73Secure Apache   Nginx MIME types with X Content Type Options nosniff - 63Secure Apache   Nginx MIME types with X Content Type Options nosniff - 13Secure Apache   Nginx MIME types with X Content Type Options nosniff - 77Secure Apache   Nginx MIME types with X Content Type Options nosniff - 82Secure Apache   Nginx MIME types with X Content Type Options nosniff - 82Secure Apache   Nginx MIME types with X Content Type Options nosniff - 57Secure Apache   Nginx MIME types with X Content Type Options nosniff - 90Secure Apache   Nginx MIME types with X Content Type Options nosniff - 13