Setting up IIS reverse proxy to preserve host headers

I have an IIS server that is hosting a number of sites and apis. These sites include Confluence and Jira instances. These products actually run their own web servers so the Application Request Routing and Url Rewrite modules are being used to reverse proxy incoming requests to documents.example.com' and 'jira.example.com' tolocalhost:8080andlocalhost:8090` - where the confluence and jira instances are running.

Now I am trying to setup a reverse proxy to a small simple-storage-server (s3) api (minio) - that is hosted on localhost:9000 - but the s3 protocol requires that the host header is part of its Message Authentication Codes.

However, when Application Request Routing reroutes a request following a URL Rewrite rule it also rewrites the host header to reflect the new destination header.

This can be disabled by setting system.webServer.proxy:preserveHostHeaders but only in ApplicationHost.config as ARR runs a the server, not the site level.

So now I have a conundrum:

If I set this setting, then the REST APIs that use host header in their MAC can function, but Confluence and Jira as their supported reverse proxy configuration expects rewritten host headers.

For reference, this sets enables host headers to be preserved

%windir%\system32\inetsrv\appcmd.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost

Solution 1:

I'm struggling with the same problem. I have a solution I don't like (and I bet you won't like it either), but it does work.

If you enable preserveHostHeaders, you can then add outbound URL Rewrite rules to remap all the cases when you do want to replace host headers.