How To Remove Response Headers In IIS

What is an HTTP Response Header?

As defined in MDN:

A response header is an HTTP header that can be used in an HTTP response and that doesn’t relate to the content of the message […] (MDN Web Doc)

In this scenario, I am using IIS version 10.0 and we are going to be requesting the default website that comes with IIS.

A typical request to “localhost” returns the following Response HTTP Headers:

Our first task is to remove the “Server” variable. This variable describes the software used by the origin server that handled the request.

Method #1

If you have IIS version 10.0 this is really simple.

  1. Go at Site level and click “Configuration Editor”

2. Navigate to “system.webServer/security/requestFiltering” and set the value of the following key to:

  • removeServerVariable: True

3. Test!

Method #2

We can use URL Rewrite Module to set the value of the “Server” variable to an empty string.

You can install this module through the Web Platform Installer.

  1. Go to site level and click the “URL Rewrite” module

2. On the “Actions” pane on the right, select “View Server Variables…”

3. On the “Actions” pane on the right, select “Add…”

4. Add a server variable called: “RESPONSE_SERVER”

5. Let's go back to the Rules and click “Add Rule(s)…”

6. Select “Outbound rules > Blank rule” and “OK”

7. Set the following values and click “Apply”

Match Section

Name: Remove Server Variable (or whatever you would like)

Matching scope: Server Variable

Variable name: RESPONSE_HEADER

Variable value: Matches the Pattern

Using: Regular Expressions

  • Pattern: .*

Action Section

Action type: Rewrite

Value: (empty string)

  • Make sure “Replace existing server variable value” is checked.

8. Test!

Bonus

Using method #2 we are going to modify “X-Powered-By” variable.

  1. Add variable to the list

2. Create an outbound rule

3. Test!

Now it is your turn, try removing or changing other Response Headers variables!

Resources

--

--

--

Love podcasts or audiobooks? Learn on the go with our new app.

A detailed explanation of pointers in Golang

All you need to know about the basics of AT Commands for Cellular IoT Modems

What is Scala and Should it be Your First Programming Language?

C++ string manipulations

How To Excel at Coding Interviews in 2021

Two women talking at work

Agile Methodology & Implementation of Features in Zomato using it.

Part 1/7 of Python-MongoDB Tutorial Series For Data : Downloading And Setting Up MongoDB On Your…

An image indicating where msi package is

Find two numbers in an array that sums up to K

Find two numbers in an array that sums up to K

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Jenkins

Adrian Jenkins

More from Medium

Unsafe Unlink

How to Assign Static IP Address in Raspberry PI

CS373 Spring 2022: Cole Weinman — Week 2

How to create a Syntropy network with a Plex Service