首页 > 解决方案 > IIS 相当于 Apache 中的 Location 标签

问题描述

我在使用端口 8090 的 Windows 服务器上安装了一个应用程序,并且我使用 IIS 应用了反向代理配置以使该应用程序在端口 443 上可用

但是,我曾经遇到过 Web 应用程序的问题,当我联系开发人员时,他们建议我在 Windows 上使用 apache 服务器并应用以下配置:

<VirtualHost *:443>
    ServerName demo.somwthing.com
    SSLEngine On
    SSLProxyEngine On 
    SSLCertificateFile ""
    SSLCertificateKeyFile ""
    SSLCertificateChainFile ""
    
    #LogLevel debug mod_rewrite.so:debug
    #LogLevel trace5
    ErrorLog C:\Server\Apache\Apache24\logs\report.txt
    CustomLog C:\Server\Apache\Apache24\logs\custom.txt \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
    
    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass /.well-known !
    
    <Location /event-stream>
        Require all granted
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule .* ws://192.168.11.132:8090%{REQUEST_URI} [P]
    </Location>
    
    <Location /system-event-stream>
        Require all granted
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule .* ws://192.168.11.132:8090%{REQUEST_URI} [P]
    </Location>
    
        <Location /dashboard-event-stream>
        Require all granted
        RewriteEngine on
        RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
        RewriteCond %{HTTP:CONNECTION} Upgrade$ [NC]
        RewriteRule .* ws://192.168.11.132:8090%{REQUEST_URI} [P]
    </Location>



    ProxyPass / http://192.168.1.132:8090/
    ProxyPassReverse / http://192.168.1.132:8090/
</VirtualHost>

我无法在 Windows 上成功运行 apache,我们仍然更喜欢 IIS,现在我能够在 IIS 中应用重写规则和条件,但我仍然不知道如何在 IIS 中转换标签,是之前配置中的location标签和Match URL一样吗?请帮助我了解位置标记及其在此配置中的作用以及如何在 IIS 中反映它

谢谢

标签: iisurl-rewritingreverse-proxywindows-server-2019

解决方案


IIS 7 及更高版本中的 URL 重写模块提供了一个导入功能,该功能极大地简化了将 Apache mod_rewrite 规则转换为 IIS URL 重写规则的过程。

更多信息可以参考这个链接:Importing Apache mod_rewrite Rules


推荐阅读