We are excited to announce that the IIS.NET Forums are moving to the new Microsoft Q&A experience. Learn more >

Reverse proxy to 2 internal IIS serversRSS

3 replies

Last post Aug 09, 2017 07:25 AM by Yuk Ding

  • Reverse proxy to 2 internal IIS servers

    Aug 03, 2017 11:04 AM|BurningRanger|LINK

    Hi,

    I'm having real problems setting up reverse proxy for 2 internet DNS names to 2 internal IIS servers.

    test1.externaldnsname.com:80 >> testA.internaldnsname.local:80

    test2.externaldnsname.com:80 >> testB.internaldnsname.local:80

    I have IIS 8.5 with ARR.


    I've enabled ARR and set the reverse proxy to testA.internaldnsname.local

    This works ok, but how do I reverse proxy for testB.internaldnsname.local?

    I've tried editing the auto-generated re-write rule, and setting a condition (HTTP_HOST, test1.externaldnsname.com)

    This continues to work, although strangely, the first time I access this page externally, it shows the default website IIS page, refreshing it then brings up the correct page.

    Then I created another URL Rewrite rule for test2.externaldnsname.com (pattern: test2.externaldnsname.com, similar condition as before, rewrite rule: http://testB.internaldnsname.local/{R:0}

    So in summary=====================
    DEFAULT AUTO-GENERATED RULE:
    pattern: *
    Condition: HTTP_HOST, test1.externaldnsname.com
    action: rewrite testA.internaldnsname.local/{R:0}
    stop processing subsequent rules: unchecked


    SECOND RULE:
    pattern: test2.externaldnsname.com
    Condition: HTTP_HOST, test2.externaldnsname.com
    action: rewrite testB.internaldnsname.local/{R:0}

    Now, the first one still has the same behaviour as before (first goes to default website IIS test page, when refreshed goes to correct internal site).
    However, the second site just goes to the default website IIS test page, regardless of how many times I refresh.

    Any help appreciated.

  • Re: Reverse proxy to 2 internal IIS servers

    Aug 04, 2017 03:14 AM|Yuk Ding|LINK

    Hi BurningRanger,

    First of all, you need to ensure both testA.internaldnsname.local and testB.internaldnsname.local have the binding host header with internal IP address. Secondly, just ensure both these domain has entry in DNS and you could access the backend site directly from the ARR server.

    Then you need to add test1.externaldnsname.com and test2.externaldnsname.com  binding in the ARR server. The last step is add this rule to IIS and enable the reverse proxy in IIS manager->server node->application request routing cache->proxy->enable.

      <rule name="reverse rewrite1">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="test1.externaldnsname.com" />
                        </conditions>
                        <action type="Rewrite" url="http://testA.internaldnsname.local/{R:0}" appendQueryString="false" />
                    </rule>
                    <rule name="reverse rewrite2">
                        <match url="(.*)" />
                        <conditions>
                            <add input="{HTTP_HOST}" pattern="test2.externaldnsname.com" />
                        </conditions>
                        <action type="Rewrite" url="http://testB.internaldnsname.local/{R:0}" appendQueryString="false" />
                    </rule>

    Did you set the default web site to localhost with unassigned IP? Just try to disable it.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.
  • Re: Reverse proxy to 2 internal IIS servers

    Aug 08, 2017 08:23 AM|BurningRanger|LINK

    - I have the binding in place for testA and testB. See below:

     

    - Both backend servers have correct DNS entries and can be accesses from the reverse proxy.

     

    " add test1.externaldnsname.com and test2.externaldnsname.com  binding in the ARR server"

    Sorry, I'm not too familiar with ARR. Where  in IIS 8.5 do I do this?

     

    - I've added the appropriate URL rewrite rules in as per your instructions

     

    - "Did you set the default web site to localhost with unassigned IP? Just try to disable it."

    Where do I go to do this?

     

  • Re: Reverse proxy to 2 internal IIS servers

    Aug 09, 2017 07:25 AM|Yuk Ding|LINK

    Hi BurningRanger,

    " add test1.externaldnsname.com and test2.externaldnsname.com  binding in the ARR server"
    
    Sorry, I'm not too familiar with ARR. Where  in IIS 8.5 do I do this?
    

    I mean you should ensure the ARR reverse proxy server has the websites with binding test1.externaldnsname.com and test2.externaldnsname.com. So that IIS will know which application pool should handle the request. In addition, you should ensure the externaldns could resolve this domain name and you could access the external domain name from external network.

     "Did you set the default web site to localhost with unassigned IP? Just try to disable it."

    I mean If you have default web site, just ensure it is stopped to avoid this site will handle the request.

    Best Regards,

    Yuk Ding

    Yuk Ding

    MSDN Community Support
    Please remember to "Mark as Answer" the responses that resolved your issue.