【问题标题】:Point a Virtual Directory in IIS to another server IP将 IIS 中的虚拟目录指向另一个服务器 IP
【发布时间】:2016-04-07 05:30:52
【问题描述】:

我有以下设置:-

IIS 服务器 7

  • 域名:abc.xyz.com

  • 虚拟目录:abc.xyz.com/myapp/

NGINX 服务器

  • 192.168.23.122

我的要求是每当有人打开 abc.xyz.com/myapp/ 时,它应该在内部指向 NGINX IP,但地址栏中的 URL 应该是 abc.xyz.com/myapp/ 以及应用程序内的更多链接和导航应该发生。

  • 可以使用 IP 从 IIS 服务器访问 NGINX 服务器。

当前的 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>

我正在点击网址:

http://localhost/myapp/

192.168.1.105 是其他系统上的 nginx 服务器,我可以从 IIS 服务器访问它。

【问题讨论】:

    标签: windows iis iis-7 server


    【解决方案1】:

    我正在使用Helicon ISAPI_Rewrite,它允许跨 ASP.NET 应用程序重写,而使用内置的 IIS 重写模块无法做到这一点。

    (请注意好像I'm wrong on this)。

    他们使用类似.htaccess 的语法来编写重写/代理规则,例如:

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

    (这是未经测试的,只是提供一个想法)。

    存在QSA 参数,因为a rewrite rule cannot capture URL parameters

    【讨论】:

    • 这是可能的,我已经使用了多年。关键是你还需要安装官方的Application Request Routing模块。
    • 很高兴知道,@Kul-Tigin。我从来没有设法让它与内置的 IIS 模块一起工作。现在会投票赞成你的答案:-)。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-28
    相关资源
    最近更新 更多