Skip to content

Instantly share code, notes, and snippets.

@xt0rted
Created October 15, 2017 01:12
Show Gist options
  • Save xt0rted/33b554069e94e00cb76f1dc327fd7e0f to your computer and use it in GitHub Desktop.
Save xt0rted/33b554069e94e00cb76f1dc327fd7e0f to your computer and use it in GitHub Desktop.
applicationHost.xdt for Kudu to force HTTPS & remove custom/server headers
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="%XDT_SITENAME%" xdt:Transform="InsertIfMissing" xdt:Locator="Match(path)">
<system.webServer xdt:Transform="InsertIfMissing">
<applicationInitialization xdt:Transform="InsertIfMissing">
<add initializationPage="/" xdt:Transform="InsertIfMissing" />
</applicationInitialization>
<httpProtocol xdt:Transform="InsertIfMissing">
<customHeaders xdt:Transform="InsertIfMissing">
<add xdt:Transform="Remove" />
</customHeaders>
</httpProtocol>
<security xdt:Transform="InsertIfMissing">
<requestFiltering removeServerHeader="true" xdt:Transform="SetAttributes(removeServerHeader)" />
</security>
<rewrite xdt:Transform="InsertIfMissing">
<rules xdt:Transform="InsertIfMissing">
<rule name="Force HTTPS" enabled="true" stopProcessing="true">
<match url="(.*)" ignoreCase="false" />
<conditions>
<add input="{HTTPS}" pattern="off" />
<add input="{WARMUP_REQUEST}" pattern="1" negate="true" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" appendQueryString="true" redirectType="Permanent" />
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment