Alexander Matusiak
Alexander Matusiak

Reputation: 1828

IIS Reverse Proxy

I've got two websites.

XX.XX.XX.XXX:5917 which is a webforms website

And

XX.XX.XX.XXX:5916 which is an mvc website.

Both websites on the same IIS 7 server. I can navigate each website, login, etc.

However, when a user goes to XX.XX.XX.XXX:5917/Report I want the content from XX.XX.XX.XXX:5916/Report to be served up, but the url to remain XX.XX.XX.XXX:5917/Report.

To do this, I'm trying to set up a reverse proxy on the 5917 site to serve up content from 5916.

When I have a redirect rule in place, I can click a link in 5917 to Reports and it will take me to 5916/Reports. This works, but changes the address bar. When I use the Rewrite rule option, absolutely nothing discernible happens. If I screw up the end url in the action bracket then the page will break, so I know it's at least evaluating the rule.

Here is the 'working' redirect rule:

<rule name="Reverse Proxy to Reports" stopProcessing="true">
    <match url="\bReport\b" />
    <action type="Redirect" url="http://XX.XX.XX.XXX:5916/{R:0}" />
</rule>

Am I missing anything? Where do I go from here?

Upvotes: 0

Views: 755

Answers (1)

Steven de Salas
Steven de Salas

Reputation: 21497

Try adding this on your XX.XX.XX.XXX:5917 WebForms web.config:

<system.webServer>
    ...
    <rewrite>
        ...
        <rules>
            <rule name="ReverseProxyInboundRuleForReports" stopProcessing="true">
                <match url="(Report/.*)" />
                <action type="Rewrite" url="http://localhost:5916/{R:1}" />
            </rule>
        </rules>
    </rewrite>
</system.webServer>

You might need 'Application Request Routing' extension on IIS for it to work though. If so then you can get it from this link:

http://www.iis.net/downloads/microsoft/application-request-routing

You can also read more about the technique on this link:

http://weblogs.asp.net/owscott/creating-a-reverse-proxy-with-url-rewrite-for-iis

Good luck!

Upvotes: 1

Related Questions