0

I try to understand how the hostname redirection system is working with Microsoft system.

I have

  • A Active Directory + DNS server (server10)
  • A main IIS server (server34 - 192.168.1.34)
  • A staging/testing IIS server (server24 - 192.168.1.24)

On my DNS server (server10) I registered several domains including

enter image description here

I have one IP that my router redirect on mn my main IIS (server34) So I created 2 websites:

  1. for my main production web api with bindings

enter image description here

  1. and another for staging api with bindings

enter image description here

But this second one an empty website because I use the URL Rewrite to redirect all query on my real staging server on server24

enter image description here

When I go on api.mydomain.com or on api-staging.mydomain.com from my network all is working fine because my DNS (server10) is properly used by my browser or my router (I don't know).

When I go api.mydomain.com or on api-staging.mydomain.com from outsite, from web, I can reach my api host by I get an error 500 for my api-staging host. This seems logic because It seems the URL Rewrite tool simply replace http://api-staging.mydomain.com/api by http://server24/api in place or redirecting the query with same header and parameters to my server24.

FYI I can properly setup the reverse proxy with Nginx of Apache solutions but I really would like to do it with IIS. It should be possible. Or maybe I must redirect the initial query base on information in my local DNS and I don't know how to do.

Last info, I don't want to have to do this in my firewall/router.

EDIT

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://server24:81/(.*)" />
                    <action type="Rewrite" value="http{R:1}://api-staging.mydomain.com/{R:2}" />
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://server24:81/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>
  • "I get an error 500 for my api-staging host" What kind of 500? There should be a sub-status. You should also edit the question to include the actual rewrite rules in applicationHost.config. – Lex Li Mar 14 at 13:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.