5

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
Gerald Schneider
  • 23,274
  • 8
  • 57
  • 89
Chris Becke
  • 161
  • 1
  • 5
  • What do you mean by "that use host header in their MAC"? – Lex Li Oct 24 '18 at 14:10
  • The value of the "Host:" header field is part of the message authentication hash used by the s3 protocol to ensure the request is from someone who has an authorized api key. So if the Host header is rewritten the s3 server can't authenticate the command and fails the operation. – Chris Becke Oct 24 '18 at 15:47

1 Answers1

3

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.