IIS と Apache の書き換えとリダイレクトが連携して動作する

IIS と Apache の書き換えとリダイレクトが連携して動作する

IISとApacheが同じサーバー上で動作しているときに問題が発生しています。具体的には、Apacheが行うリダイレクトでは、Webサイトのドメインがターゲットドメインに置き換えられません。例を示します。 https://s3.amazonaws.com/company-documentation/Help/Product/index.html 代わりにリダイレクトします https://website.company.com/company-documentation/Help/Product/index.html

現在、IIS がすべてのトラフィックを Apache にリダイレクトし、非標準ポート番号を隠すために URL を書き換えるように設定しています。以下は、私が設定した IIS 書き換えルールと Apache htaccess リダイレクトです。

以下は、Apache の htaccess ルート フォルダー リダイレクト ルールです。

# Turn mod_rewrite on
RewriteEngine On

RewriteRule "^Documentation/Product/(.*)$" "https://s3.amazonaws.com/company-documentation/Help/Product/$1" [L,NC]

これは IIS web.config です:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(.*)" />
                    <action type="Rewrite" url="http://website.company.com:8081/{R:1}" />
                    <serverVariables> 
                        <set name="HTTP_ACCEPT_ENCODING" value="" /> 
                    </serverVariables> 
                </rule>
            </rules>
            <outboundRules>
                <rule name="ReverseProxyOutboundRule1" preCondition="ResponseIsHtml1">
                    <match filterByTags="A, Form, Img" pattern="^http(s)?://website.company.com:8081/(.*)" />
                    <action type="Rewrite" value="http{R:1}://website.company.com/{R:2}" />
                </rule>
                <preConditions>
                    <preCondition name="ResponseIsHtml1">
                        <add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

Apache htaccess の書き換えは、Web サーバーとして Apache のみがインストールされている現在の運用サーバーでは正常に動作します。新しいサーバーでは、CRM と Web サイトの両方を提供するために、同じサーバーに IIS と Apache の両方がインストールされている必要があります。これを動作させる方法について何かアドバイスはありますか?

編集: サーバーにインストールされている ADFS はポート 80 と 443 を使用するため、Apache サーバーが CRM 要求を IIS にリダイレクトすることが機能するかどうかはわかりません。これらのポートは、Apache を HTTP および HTTPS 要求の既定の要求ハンドラーにするために使用する必要があります。

答え1

解決策は、ARR プロキシ設定に移動し、「応答ヘッダーのホストを逆書き換えする」のチェックを外すことです。出典:https://forums.iis.net/t/1176725.aspx

関連情報