Add response header base on missing reqest header



I'm not sure if this is possible or not, but I would like to add a response header when a certain request header is missing. For example:

When a client sends a request to my exchange server without a "Authenticate" header (i.e. anonymous request), I would like to add a "Connection" header in the response. Is this possible?


1 comment

Barry Gleeson

Hi SC,
This should be possible through content rules by 1. matching the Authenticate Header and then 2. adding a connection header if this is matched,

  1. Create Content Rule to detect presence of Authenticate Method

Rules & Checking > Content Rules and click Create New.

Rule Name: MatchAuthHeader
Rule Type: Content Matching
Match Type: Regular Expression
Header Field : authenticate
MatchString: .*

2.Create two Sub Virtual Services, subvs-auth subvs-noauth

On the Main VS Enable Content Switching by clicking Enable in the Advanced Properties section of the Virtual Service modify screen.

Then under the SubVs apply the new Content Rule to subvs-auth and "default" to "subvs-noauth"

  1. Now that the traffic is separated you can apply the Connection Header to traffic going through the "subvs-noauth" SubVS. This once again will require creating a Content Rule to Add Header.

Rule Name: ConnectionHeader
Rule Type: Add Header
Header Field to be Added: Connection
Value of Header Field to be Added: <Value can be specified here>

This can then be applied in the SubVs under HTTP Header Modifications, inside the Response Rules section.