2017-04-21 22 views
0

我有一個IIS Web服務器,它被設置爲處理* .myapp.com的所有請求。我們也有設置了自定義域名的客戶,例如custom.customer.com作爲CNAME要customer.myapp.com域名從domain.com/pathA重定向到domainA.com

我有一個要求,處理好以下幾個:

  • 請求custom.customer.com/pathA需要被重定向到。 internal-app.com
  • 請求custom.customer.com/pathB需要被重定向到b.internal-app.com

我現在的問題是,這個不能做在DNS級別(因爲它涉及路徑)。另外,無論「重定向」是什麼,我都希望客戶始終能夠看到他的自定義域。就像他永遠不應該看到internal-app.com或myapp.com一樣。

這有可能以任何方式嗎?

回答

0

這是可能的反向代理。

1)您需要安裝URL RewriteARR module爲IIS

2)啓用ARR。在Application Request Routing頁面上,選擇Enable proxy

3)創建重寫規則

<rewrite> 
     <rules> 
      <rule name="rewrite custom.customer.com/patha" stopProcessing="true"> 
       <match url="patha" /> 
       <conditions logicalGrouping="MatchAll"> 
        <add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" /> 
       </conditions> 
       <action type="Rewrite" url="http://a.internal-app.com/" /> 
      </rule> 
      <rule name="rewrite custom.customer.com/pathB" stopProcessing="true"> 
       <match url="pathb" /> 
       <conditions logicalGrouping="MatchAll"> 
        <add input="{HTTP_HOST}" pattern="^custom.customer.com$" ignoreCase="true" /> 
       </conditions> 
       <action type="Rewrite" url="http://b.internal-app.com/" /> 
      </rule> 
     </rules> 
    </rewrite> 

附:你的資源可能有問題(圖片,樣式,CSS,JS)。因爲您的html可能包含資源的絕對路徑

您可以在作者創建用於修復相關URL的出站規則時檢查此帖子https://blogs.iis.net/carlosag/setting-up-a-reverse-proxy-using-iis-url-rewrite-and-arr