简体   繁体   English

反向代理不适用于在IIS上使用ARR和URL重写的ADFS

[英]Reverse proxy not working for ADFS using ARR and URL-Rewrite on IIS

I am trying to implement reverse proxy using ARR and URL rewrite module on IIS. 我正在尝试在IIS上使用ARR和URL重写模块实现反向代理。 I have two servers called A and B. I have installed ADFS on server "A" and server "B" used only for reverse proxy. 我有两个分别称为A和B的服务器。我已在仅用于反向代理的服务器“ A”和服务器“ B”上安装了ADFS。 I have installed ARR and URL-Rewrite modules on server "B". 我已经在服务器“ B”上安装了ARR和URL重写模块。

For example server "A" domain name "myadfs1.com" and server "B" domain name "myproxy.com". 例如,服务器“ A”域名“ myadfs1.com”和服务器“ B”域名“ myproxy.com”。 The federation server login page URL - https://myadfs1.com/adfs/ls/IdpInitiatedSignon.aspx 联合身份验证服务器登录页面URL- https://myadfs1.com/adfs/ls/IdpInitiatedSignon.aspx

Problem statement - 问题陈述 -
When I am accessing direct ADFS URL ie https://myadfs1.com/adfs/ls/IdpInitiatedSignon.aspx , getting response and ADFS login page opening fine. 当我访问直接的ADFS URL时,即https://myadfs1.com/adfs/ls/IdpInitiatedSignon.aspx ,得到的响应和ADFS登录页面的打开情况都很好。 There is no problem. 没有问题。 But when I am trying to access ADFS login page via proxy ie https://myproxy.com/adfs/ls/IdpInitiatedSignon.aspx getting 503 errors ie the service is unavailable. 但是,当我尝试通过代理(即https://myproxy.com/adfs/ls/IdpInitiatedSignon.aspx)访问ADFS登录页面时,出现503错误,即服务不可用。

Below rules I am using for rewrite – 遵循我用于重写的规则-

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
            <rules>
                <clear />
                <rule name="ReverseProxyInboundRule2" stopProcessing="true">
                    <match url="[a][d][f][s](.*)" />
                    <conditions logicalGrouping="MatchAll" trackAllCaptures="false">
                        <add input="{HTTPS}" pattern="On" />
                    </conditions>
                    <action type="Rewrite" url="https://myadfs1.com/adfs{R:1}" appendQueryString="true" logRewrittenUrl="true" />
                </rule>                
            </rules>
        </rewrite>
        <tracing>
            <traceFailedRequests>
                <add path="*">
                    <traceAreas>
                        <add provider="ASP" verbosity="Verbose" />
                        <add provider="ISAPI Extension" verbosity="Verbose" />
                        <add provider="WWW Server" areas="Authentication,Security,Filter,StaticFile,CGI,Compression,Cache,RequestNotifications,Module,FastCGI,WebSocket" verbosity="Verbose" />
                    </traceAreas>
                    <failureDefinitions timeTaken="00:00:00" statusCodes="400-600" />
                </add>
            </traceFailedRequests>
        </tracing>
    </system.webServer>
    <system.web>
        <identity impersonate="false" />
    </system.web>
</configuration>

Some observation – 一些观察–

If I am trying to access https://myproxy.com/adfs/ls/IdpInitiatedSignon.aspx URL then I am not getting any log on IIS on proxy server. 如果我尝试访问https://myproxy.com/adfs/ls/IdpInitiatedSignon.aspx URL,则代理服务器上的IIS上没有任何日志。 But If I try same URL just replacing "adfs" to "adfs1" then IIS logging the request and getting 404 error. 但是,如果我尝试使用相同的URL,只是将“ adfs”替换为“ adfs1”,则IIS将记录请求并得到404错误。

So I am looking for help to configure reverse proxy for my ADFS access. 因此,我正在寻求有关为ADFS访问配置反向代理的帮助。

I have just stumbled on this myself, it turned out that something wasn't removed on my IIS server when I installed ADFS on it in the past and later removed it. 我自己偶然发现,发现过去在我的IIS服务器上安装ADFS并随后将其删除时,并未将某些内容删除。

The http.sys component in Windows has a feature called 'URL reservations', which allow multiple applications to work on the same hostname without interfering with eachother. Windows中的http.sys组件具有称为“ URL保留”的功能,该功能允许多个应用程序在相同的主机名上工作,而不会互相干扰。 This enables IIS, ADFS, Remote Desktop Gateway and so on to run on the same server. 这使IIS,ADFS,远程桌面网关等可以在同一服务器上运行。

I ran the following command on my server: 我在服务器上运行了以下命令:

netsh http show urlacl

This listed me all URL reservations, and a couple of them were for ADFS - despite it no longer being installed on that particular machine! 这列出了我所有的URL保留,其中一些保留给ADFS使用-尽管不再在该特定计算机上安装它了! I then issued these commands: 然后,我发出了以下命令:

netsh http delete urlacl http://+:80/adfs/
netsh http delete urlacl https://+:443/adfs/
netsh http delete urlacl https://+:49443/adfs/
netsh http delete urlacl https://+:443/FederationMetadata/2007-06/

Once having done this, everything started to work. 完成此操作后,一切便开始起作用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM