Skip to content

Instantly share code, notes, and snippets.

@nikanos
Last active October 31, 2022 20:08
Show Gist options
  • Save nikanos/a32ebc57edd6df877f3aa58f7eb94e36 to your computer and use it in GitHub Desktop.
Save nikanos/a32ebc57edd6df877f3aa58f7eb94e36 to your computer and use it in GitHub Desktop.
IIS URLRewrite Rule - Remove Port From ForwardedFor Header
<?xml version="1.0"?>
<configuration>
<configSections>
<!-- config sections -->
</configSections>
<system.webServer>
<rewrite>
<rules>
<rule name="Remove Port From ForwardedFor Header">
<match url="(.*)" />
<serverVariables>
<set name="HTTP_X_FORWARDED_FOR"
value="{C:1}{C:3}" />
</serverVariables>
<action type="None" />
<conditions trackAllCaptures="true">
<add input="{HTTP_X_FORWARDED_FOR}"
pattern="^([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}):([0-9]{1,5})(.*)$" />
</conditions>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment