Ash.R
Ash.R

Reputation: 1

IIS Rewrite and reverse proxy for multiple applications

I have an IIS 10 with a website configured on that. There are multiple Applications underneath that website. MyWebsite/app1 - MyWebsite/app2 - MyWebsite/app3

I Have another server(let's call it EndServer) hosting 3 websites on 3 different ports.

well, now what I wanna do is using IIS as a reverse proxy to redirect and MASK the application 1 to one of those websites in 2nd server and application 2 to another one. at the end, Users will enter https://mywebsite/app1 and they will see the contents of website 1 in the Endserver.

Note: it is important for me that end Users see the URL like as https://mywebsite/app1/

how shall I edit the Rule below:

<rewrite>
        <rules>
            <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                <match url="(.*)" />
                <action type="Rewrite" url="http://endserver:8052/{R:1}" />
                <conditions trackAllCaptures="true">    
                </conditions>
           </rule>
  </rewrite>

Thanks A.

Upvotes: 0

Views: 1932

Answers (2)

Ash.R
Ash.R

Reputation: 1

Thanks for your answer. I got same error. as you see below /App1 is missing in the URL after localhost:Port localhost:8888/assets/styles/Custom.css?m=1549903616.0

I believe the trouble is with rewriting the response URL. I don't know who can I add the missing part in URL.

Regards.

Upvotes: 0

Brando Zhang
Brando Zhang

Reputation: 28397

According to your description, I suggest you could try to use below url rewrite rule.

<rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{URL}" pattern="^/app1/(.*)" />
                    </conditions>
                    <action type="Rewrite" url="http://endserver:8052/{C:1}" />
                </rule>
 <rule name="ReverseProxyInboundRule2" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions trackAllCaptures="true">
                        <add input="{URL}" pattern="^/app2/(.*)" />
                    </conditions>
                    <action type="Rewrite" url="http://endserver:8053/{C:1}" />

                </rule>

Upvotes: 2

Related Questions