﻿# 在 IIS 8 安裝設定 ARR 與 Web Farm Framework 的注意事項

[Application Request Routing](http://www.iis.net/downloads/microsoft/application-request-routing) (ARR) 搭配 [Web Farm Framework](http://www.iis.net/downloads/microsoft/web-farm-framework) (WFF) 是個很好的產品組合，且整個 Windows Azure 雲端平台也都是用這些免費套件來實現網站之間的負載平衡，其穩定度與效能不在話下，但在台灣卻鮮少聽到有公司採用 ARR 與 WFF 來實現網站負載平衡，連分享文章都看不到幾篇，實在有點可惜。前陣子幫客戶裝了 ARR 與 WFF 來實現網站負載平衡，不過這次安裝到 IIS8 的時候有遇到一些問題，因此把這些該注意的事項都整理下來，以減少下次設定時犯錯的機會。

**大致 Web Farm 主機配置**

-   ARR/WFF 主機 (獨立主機或VM)
-   Web 主機 (共 1 ~ 8 台不等)
-   Web 主機之間的檔案同步採用 DFS (分散式檔案系統) 架構
-   Session 主機 ( 可使用 ASP.NET State Service 或 SQL Server 作為儲存地點 )

**ARR/WFF 主機設定**

-   只能有一個 **Default Web Site** 站台 (因為設定了全站的 Rewrite 規則)
-   若要安裝 SSL 憑證，需先匯入憑證，並將該憑證 **繫結** (Binding) 於 **Default Web Site** 站台
-   若要讓連接的使用者在一段時間內同時造訪同一台 Web 主機，可以啟用 **Client Affinity** 設定  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/48f8a8283f234c4ce4d3-image_2023.png)  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/4a5d2d6ffc4a75bd8668-image_2024.png)
-   千萬不要勾選 **Enable disk cache** (預設是勾選的)，這會讓你的網站出現莫名的 **HTTP 502.3** 錯誤  
    ( 註: 此問題我已經回報給微軟，問題也可以 100% 重現，只是至今無解! )  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/5c236740e45e5e3757c6-image_2025.png)  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/a5ea794e31b210ab3294-image_2026.png)

**Web 主機設定**

-   記得在【**IP 地址與網域限制**】模組的「編輯功能設定」勾選 **啟用 Proxy 模式** (一定要)  
    ![Edit IP and Domain Restrictions Settings - Enable Proxy Mode](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/bafc688de4a0bd513bc3-image_2027.png "Edit IP and Domain Restrictions Settings - Enable Proxy Mode")  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/e9e90561c7cd6b2609b6-image_2028.png)
-   在【**IP 地址與網域限制**】加入 ARR 主機的 IP 位址 (提高網站安全性)  
    ![](https://stwillblogassets.blob.core.windows.net/files/images/external/stwillblogassets.blob.core.windows.net/cac298baecaf4f6d13be-image_2029.png)

**心得分享**

像我用 ARR 搭配 WFF 已經好多年了，無論是效能或品質都很不錯，也可以乘載極大的流量，但每次看到客戶寧願選擇貴森森的硬體負載平衡器，然後抱怨每年的保固費用太高；也不願意採用微軟推出的軟體負載平衡器產品 (而且還是免費的)，都覺得替他們的 ***小朋友*** (鈔票的意思) 感到可惜。

這個想法出現過好幾次，我想，要是那些有購買**硬體負載平衡器**的公司找我們當顧問，由我們來協助他們導入這套免費的**軟體負載平衡器**方案 (ARR + WFF + URL Rewrite)，**每年的顧問費**就收**硬體負載平衡器**的**年度保固費**用就夠了，這不知道該有多好！ ^\_^

**相關連結**

-   [Application Request Routing : The Official Microsoft IIS Site](http://www.iis.net/downloads/microsoft/application-request-routing)

-   [Planning for ARR](http://www.iis.net/learn/extensions/planning-for-arr)
-   [Installing Application Request Routing (ARR)](https://learn.microsoft.com/en-us/iis/extensions/installing-application-request-routing-arr/install-application-request-routing-version-2)
-   [Configuring Application Request Routing (ARR)](https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/demonstration-of-shared-hosting-deployment-with-arr)
-   [Troubleshooting Application Request Routing](http://www.iis.net/learn/extensions/troubleshooting-application-request-routing)
-   [URL Rewrite Module](http://www.iis.net/learn/extensions/url-rewrite-module)

-   [Web Farm Framework : The Official Microsoft IIS Site](http://www.iis.net/downloads/microsoft/web-farm-framework)

-   [Microsoft Web Farm Framework 2.0 for IIS 7](http://www.iis.net/learn/web-hosting/microsoft-web-farm-framework-20-for-iis-7) (Articles)

-   [URL Rewrite : The Official Microsoft IIS Site](http://www.iis.net/downloads/microsoft/url-rewrite)

-   [URL Rewrite Module](http://www.iis.net/learn/extensions/url-rewrite-module) (Articles)

-   [SSL off-loading in Application Request Routing](https://blogs.iis.net/wonyoo/ssl-off-loading-in-application-request-routing/)
-   [IIS 8.0 Dynamic IP Address Restrictions](http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions)

-   [Configuring IIS for Proxy Mode](http://www.iis.net/learn/get-started/whats-new-in-iis-8/iis-80-dynamic-ip-address-restrictions#TOC301448453)

-   [Troubleshooting Cache Items ARR V2](http://www.iis.net/learn/extensions/troubleshooting-application-request-routing/troubleshooting-cache-items-arr-v2)
-   [Manually Override Cache-control Directives Using Application Request Routing](https://learn.microsoft.com/en-us/iis/extensions/configuring-application-request-routing-arr/manually-override-cache-control-directives-using-application-request-routing)
-   [Client-ip not logged on application server when using ARR](https://blogs.iis.net/anilr/client-ip-not-logged-on-content-server-when-using-arr/)
-   [Troubleshooting ARR 502.3 Errors](http://jeffgraves.me/2012/06/11/troubleshooting-arr-503-2-erros/)
-   Windows 2008 R2 DFS (分散式檔案系統) HA 架構實作及進階設定(含AD架構)
