How can we set proxy headers in IIS rewrite module
In nginx we have something like
server {
location / {
# we add a custom-host parameter in the header
# which corresponds to the domain for which the certificates can be viewed
proxy_set_header custom-host your-domain.com;
proxy_pass https://certificate-testsite.com;
}
}
What is equivalent to that in IIS. How we can set proxy header (custom-host) in IIS? I have tried using URL rewrite module and set serverVariables like this:
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="ReverseProxyInboundRule1" stopProcessing="true">
<match url="(.*)" />
<action type="Rewrite" url="https://certificate-testsite.com/{R:1}" />
<serverVariables>
<set name="HTTP_custom_host" value="your-domain.com" />
</serverVariables>
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="HTTP_custom_host" />
</rewriteMaps>
</rewrite>
</system.webServer>
</configuration>
But that doesn't work. Thanks
There is no exact equivalent in IIS, after all IIS and NGINX are different web servers with different configuration syntax and functionality. If you want to implement similar functionality on IIS, you may consider using the ARR module and URL Rewrite module. ARR allows you to enable a reverse proxy, and the URL Rewrite module allows you to create reverse proxy rules and set server variables.
In IIS, the serverVariables collection allows you to access server-specific variables. However, it is important to note that changes made to server variables in the server environment may not be directly reflected in the request headers visible in the client browser.
Reference links:
Setting HTTP request headers and IIS server variables
Reverse Proxy with URL Rewrite v2 and Application Request Routing
Adding a custom header to ARR requests