« Previous Next »

Thread: Reverse Proxy using Rewrite Maps

Last post 08-20-2009 1:50 PM by anilr. 10 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (11 items)

Sort Posts:

  • 06-23-2009, 9:52 AM

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Reverse Proxy using Rewrite Maps

     I have basic reverse proxys working but I would like to use Rewrite Maps as I potentially have many static pairs that I need to match, not conforming to a standard necessarily.

    Currently I have the following rule.

     <rewrite>
                <rules>
                    <clear />
                    <rule name="ReverseProxy">
                        <match url=".*" />
                        <conditions logicalGrouping="MatchAll">
                            <add input="{StaticMap:{Request_URI}}" pattern="(.+)" />
                        </conditions>
                        <action type="Rewrite" url="http://172.28.75.31:90{C:0}" />
                    </rule>
                </rules>
                <rewriteMaps>
                    <rewriteMap name="StaticMap" defaultValue="/server/">
                        <add key="/server/xhtml/user/fi54321" value="/54321" />
                        <add key="/server/xhtml/user/fi12345" value="/12345" />
                    </rewriteMap>
                </rewriteMaps>
            </rewrite>

     

    So basically I want  http://mydomain.com/54321 to get rewritten to http://172.28.75.31:90/server/xhtml/user/fi54321

    When I enter  http://mydomain.com/54321 I get a 404. After putting in the defaultValue for the rewriteMap it hits that /server/ folder so it appears neither of the two map items actually matches.

     

  • 06-23-2009, 12:34 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Reverse Proxy using Rewrite Maps

    Your rewriteMap should look like this

     <rewriteMap name="StaticMap" defaultValue="/server/">
        <add key="54321" value="/server/xhtml/user/fi54321" />
        <add key="12345" value="/server/xhtml/user/fi12345" />
    </rewriteMap>

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 06-23-2009, 1:59 PM In reply to

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Re: Reverse Proxy using Rewrite Maps

     That gets me a little further I think but once I flipped the key value pairs and enter http://domain.com/12345 it actuall redirected me to http://domain.com/server/xhtml/user/fi12345 showing me them the "defaultValue" page.

    If I change
    <action type="Rewrite" url="http://172.28.75.31:90{C:0}" />
    to
    <action type="Rewrite" url="http://172.28.75.31:90{C:1}" />

    IIS responds with a 502 error.

  • 06-23-2009, 3:53 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Reverse Proxy using Rewrite Maps

    Since you say you have basic reverse proxy working, I assume that you have ARR installed and configured.  Can you collect failed request trace log with the new rules?

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 06-23-2009, 4:24 PM In reply to

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Re: Reverse Proxy using Rewrite Maps

     Sure thing. Here it goes.


  • 06-24-2009, 12:42 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Reverse Proxy using Rewrite Maps

    It is impossible to view like this - can you e-mail me the file at anil (dot) ruia (at) microsoft (dot) com?

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 06-25-2009, 9:48 AM In reply to

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Re: Reverse Proxy using Rewrite Maps

     Thank you Anil. I sent you an email and deleted above XML.

  • 07-30-2009, 4:13 PM In reply to

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Re: Reverse Proxy using Rewrite Maps

     Anil - sorry I have not followed up earlier but did you get a chance to look at the trace I had sent you?

  • 07-30-2009, 4:18 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Reverse Proxy using Rewrite Maps

    I must have missed it - can you e-mail it to me again - please include link to this thread in your e-mail.

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
  • 08-20-2009, 10:23 AM In reply to

    • micxba
    • Not Ranked
    • Joined on 06-20-2005, 9:42 PM
    • Posts 9

    Re: Reverse Proxy using Rewrite Maps

     Have you had a chance to take a look? I have resend the zip file.

  • 08-20-2009, 1:50 PM In reply to

    • anilr
    • Top 10 Contributor
    • Joined on 05-23-2006, 6:13 PM
    • Redmond, WA
    • Posts 2,247

    Re: Reverse Proxy using Rewrite Maps

    I do not see it in my inbox - when did you send it and what is the e-mail address from which you sent it?

    Anil Ruia
    Senior Software Design Engineer
    IIS Core Server
Page 1 of 1 (11 items)