I try to configure a reverse proxy in the IIS. This required to set some HTTP headers. I was able to add the follow HTTP headers:
- X-Forwarded-Proto
- X-Forwarded-Port
- X-Forwarded-Host
This is possible by adding and setting server variables with related names. The webconfig look like:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="^foobar(.*)" />
<action type="Rewrite" url="http://localhost:9999/{R:1}" />
<serverVariables>
<set name="HTTP_X_FORWARDED_PORT" value="80" />
<set name="HTTP_X_FORWARDED_HOST" value="localhost" />
<set name="HTTP_X_FORWARDED_PROTO" value="http" />
<set name="HTTP_X_FORWARDED_PREFIX" value="/foobar" />
<set name="HTTP_X_FORWARDED_CONTEXT" value="/foobar" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
But I'm out of luck for the HTTP headers X-Forwarded-Context or X-Forwarded-Prefix. Also adding the server variables has no effect.