2

IIS has several websites:

  • domain1.com
  • a.domain2.com
  • b.domain2.com

There is also a TomCat running on

localhost:8087

The challenge is how to expose the TomCat externally as

b.domain2.com

What I did:

  • Enabled Proxy in ARR in IIS
  • Added Reverse Proxy URL Rewrite rules on b.domain2.com

    <rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://localhost:8087/{R:1}" />
            </rule>
          </rules>
        <outboundRules>
            <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1" >
                <match filterByTags="A, Form, Img" pattern="^http(s)?://localhost:8087/(.*)" />
                <action type="Rewrite" value="http{R:1}://femiscan.a2itsolutionsllc.com/{R:2}" />
            </rule>
    
            <preConditions>
                <preCondition name="ResponseIsHtml1">
                    <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                </preCondition>
            </preConditions>
        </outboundRules>
    </rewrite>
    

What I see:

Locally if I navigate to

http://b.domain2.com 

my browser shows TomCat website as

http://localhost:8087 

(Why?)

Externally if I navigate in Chrome to

http://b.domain2.com 

it tries to tunnel to

http://localhost:8087

If I navigate in IE it returns 500 error (Fiddler: HTTP/1.1 500 URL Rewrite Module Error.)

Question: What am I doing wrong? Can it be done and how?

1
  • This might be better addressed in the SuperUser SE.
    – mdpc
    Dec 20, 2012 at 6:07

1 Answer 1

4

Your Action is set to Rewrite so it is rewriting the URL.

In IIS Manager:

  • Right-click Server Farms, click "Create Server Farm". Give it some name.
  • Put the fully-qualified domain name to your Tomcat instance in the "Server name or address" field
  • Click "Advanced settings...", expand "applicationRequestRouting" and change httpPort to 8087
  • Click "Yes" when prompted to create a rewrite rule
  • Click the newly created farm under "Server Farms" in the pane on the left side of the window
  • Open "Routing Rules" on the Server Farm feature view page
  • Click the "URL Rewrite..." link on the right pane
  • Remove the old attempted Tomcat rewrite rule
  • Click "Add Rule(s)..." at the top of the right pane, choose "Blank rule"
  • Give it a name
  • In the Match URL pane:
    • Requested URL: Matches the Pattern
    • Using: Regular Expressions
    • Pattern: *
  • Expand the Conditions pane, click "Add"
    • Condition input: {HTTP_HOST}
    • Check if input string: Matches the pattern
    • Pattern: b.domain2.com
    • Check Ignore Case
  • In the Action pane:
    • Action type: Route to Server Farm
    • Scheme: http://
    • Server farm: (the name of your server farm)
    • Path: {R:1} (NOTE: This may need some tinkering but judging by your example it should work)
  • Click "Apply" on the right pane and your
1
  • The only thing that I did different was making the URL pattern .* instead of * in the Match URL pane, and everything worked perfectly. Jan 11, 2015 at 20:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .