IIS 和 Apache 一起重寫和重定向

IIS 和 Apache 一起重寫和重定向

我在 IIS 和 apache 在同一伺服器上工作時遇到一些問題。具體來說,apache 所做的任何重新導向都不會用目標網域取代網站網域。這是一個範例:嘗試重定向到 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 重寫在目前僅安裝 apache 作為 Web 伺服器的生產伺服器上運作良好。新伺服器需要在同一台伺服器上安裝 IIS 和 apache,以同時為 CRM 和網站提供服務。關於如何進行這項工作有什麼建議嗎?

編輯:我不確定將 Apache 伺服器重新導向到 IIS 來處理 CRM 請求是否有效,因為伺服器上安裝的 ADFS 使用連接埠 80 和 443,需要使用這些連接埠使 Apache 成為 HTTP 和 HTTPS 請求的預設請求處理程序。

答案1

解決方案是進入 ARR 代理設定並取消選取「在回應標頭中反向重寫主機」。來源:https://forums.iis.net/t/1176725.aspx

相關內容