1

I have the following setup:-

IIS Server 7

  • domain : abc.xyz.com

  • virtual directory : abc.xyz.com/myapp/

NGINX Server

  • 192.168.23.122

My requirement is to whenever someone opens abc.xyz.com/myapp/ it should point to NGINX IP internally but the URL in the address bar should be abc.xyz.com/myapp/ and further links and navigation within the application should happen.

  • NGINX server is accessible from the IIS server using IP.

Current Web.config

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyRuleForNginx" stopProcessing="true">
                    <match url="(.*)" />
                    <conditions>
                        <add input="{CACHE_URL}" pattern="^(http?)://" />
                    </conditions>
                    <action type="Rewrite" url="{C:1}://192.168.1.105/{R:1}" />
                </rule>
            </rules>
        </rewrite>
</system.webServer>

I am hitting the url:

http://localhost/myapp/

192.168.1.105 is a nginx server on other system which I am able to access from the IIS server.

Vinay Ranjan
  • 294
  • 3
  • 14

1 Answers1

1

I'm using Helicon ISAPI_Rewrite which allows for cross-ASP.NET-application rewrites, which cannot be done with the built-in IIS rewrite module.

(Please note that it seems I'm wrong on this).

They are having a .htaccess-like syntax for writing the rewrite/proxy rules, e.g.:

...
RewriteEngine on
RewriteBase /

RewriteRule ^/myapp/(.*?)$ http://localhost/myapp/ [QSA,P]
...

(This is untested, just to give an idea).

The QSA parameters are present, because a rewrite rule cannot capture URL parameters.

Community
  • 1
  • 1
Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
  • 1
    It's possible and I'm using for years. The key is you also need to install official Application Request Routing module. – Kul-Tigin Jan 03 '16 at 17:53
  • 1
    Good to know, @Kul-Tigin. I've never managed to get it working with the built-in IIS module. Will upvote your answer now :-). – Uwe Keim Jan 03 '16 at 18:01