title: Remove Server header on response on 500 HTTP Error
body: <p>I have a REST API service deployed as an Azure App Service and i been trying to remove the Server header from response.</p>
  
  <p>I tried adding a custom outgoing rule to Rewrite module.</p>
  
  <p>In web.config i have</p>
  
  <pre><code>&lt;rewrite&gt;       
   &lt;outboundRules&gt;      
    &lt;rule name="Change Server Header"&gt;        
    &lt;match serverVariable="RESPONSE_Server" pattern=".+" /&gt;          
  &lt;action type="Rewrite" value="My Server" /&gt;        
    &lt;/rule&gt;      
   &lt;/outboundRules&gt; 
  &lt;/rewrite&gt;  
  </code></pre>
  
  <p>I also applied a applicationHost.xdt transformation to applicationHost.config in order to add the RESPONSE_Server variable</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;  
  &lt;configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"&gt; 
    &lt;configSections&gt; 
      &lt;sectionGroup name="system.webServer" xdt:Locator="Match(name)"&gt; 
        &lt;sectionGroup name="rewrite" xdt:Locator="Match(name)"&gt; 
          &lt;section name="allowedServerVariables" overrideModeDefault="Allow" xdt:Locator="Match(name)" xdt:Transform="SetAttributes(overrideModeDefault)" /&gt;
        &lt;/sectionGroup&gt; 
      &lt;/sectionGroup&gt; 
    &lt;/configSections&gt;
      &lt;system.webServer&gt; 
          &lt;rewrite&gt; 
              &lt;allowedServerVariables&gt; 
              &lt;add name="RESPONSE_Server" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)" /&gt; 
            &lt;/allowedServerVariables&gt; 
          &lt;/rewrite&gt;  
      &lt;/system.webServer&gt;  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>But i still see the Server response http header on a request like following which returns a 500 HTTP status code</p>
  
  <p><a href="https://api.internaltest.com/%3a/" rel="nofollow noreferrer">https://api.internaltest.com/%3a/</a></p>
  
  <p>The rewrite rule works in local IIS it removes the http header successfully... but not when doing it in Azure App Service.</p>
  
  <p>Please tell me what i'm missing.</p>
  
  <p>I mention that i have removeServerHeader="true" in web.config also but it only removes the server header on 404 bad request, not on 500 status code.</p>
  
  <pre><code>&lt;security&gt;
        &lt;requestFiltering removeServerHeader="true"&gt;
          &lt;requestLimits maxAllowedContentLength="2147483647" /&gt;
        &lt;/requestFiltering&gt;
      &lt;/security&gt;
  </code></pre>
  
  <p>Hope anyone can help me,</p>
  
  <p>Thank you</p>