共用方式為


教學課程:使用 Azure 入口網站建立 Azure Front Door 的 WAF 原則

本教學課程說明如何建立基本的 Web 應用程式防火牆 (WAF) 原則,並將其套用至 Azure Front Door 的前端主機。

在本教學課程中,您會了解如何:

  • 建立 WAF 原則。
  • 將其與前端主機建立關聯。
  • 設定 WAF 規則。

必要條件

建立 Azure Front Door 執行個體或 Azure Front Door 標準或進階設定檔。

建立 WAF 原則

首先,使用 Azure 入口網站,建立具有受控預設規則集 (DRS) 的基本 WAF 原則。

  1. 在畫面的左上方,選取 [建立資源]。 搜尋 WAF,選取 [Web 應用程式防火牆 (WAF)],然後選取 [建立]

  2. 在 [建立 WAF 原則] 頁面的 [基本] 索引標籤中,輸入或選取下列資訊,並接受其餘設定的預設值:

    設定
    原則適用對象 選取 [全域 WAF (Front Door)]
    Front Door 分層 在 [傳統]、[標準] 和 [進階] 服務層級中進行選取。
    訂用帳戶 選取 Azure 訂閱。
    資源群組 選取您的 Azure Front Door 資源群組名稱。
    原則名稱 輸入 WAF 原則的唯一名稱。
    原則狀態 設定為 [已啟用]

    Screenshot that shows the Create a W A F policy page, with the Review + create button and list boxes for the subscription, resource group, and policy name.

  3. 在 [關聯] 索引標籤選取 [與 Front Door 設定檔建立關聯],輸入下列設定,然後選取 [新增]

    設定
    Front Door 設定檔 選取您的 Azure Front Door 設定檔名稱。
    網域 選取要與 WAF 原則建立關聯的網域,然後選取 [新增]

    Screenshot that shows the Associate a Front door profile page.

    注意

    如果網域與 WAF 原則相關聯,網域會顯示為灰色。您必須先從相關聯的原則中移除網域,然後將網域與新的 WAF 原則重新建立關聯。

  4. 選取 [檢閱 + 建立]>[建立]

設定 WAF 規則 (選擇性)

請遵循下列步驟設定 WAF 規則。

變更模式

當您建立 WAF 原則時,WAF 原則預設會處於 [偵測] 模式。 在 [偵測] 模式中,WAF 不會封鎖任何要求。 此時會將符合 WAF 規則的要求記錄在 WAF 記錄中。 若要查看 WAF 的實際效果,您可以將模式設定從 [偵測] 變更為 [預防]。 在 [防護] 模式中,會封鎖與已定義規則相符的要求,並記錄於 WAF 記錄檔中。

Screenshot that shows the Overview page of the Azure Front Door WAF policy that shows how to switch to Prevention mode.

自訂規則

若要建立自訂規則,在 [自訂規則] 區段下,選取 [新增自訂規則],開啟自訂規則設定頁面。

Screenshot that shows the Custom rules page.

以下範例說明如何設定自訂規則,在查詢字串包含 blockme 時封鎖要求。

Screenshot that shows the custom rule configuration page showing settings for a rule that checks whether the QueryString variable contains the value blockme.

預設規則集

Azure Front Door 的進階和傳統層預設會啟用 Azure 管理的預設規則集。 Azure Front Door 進階層目前的 DRS 是 Microsoft_DefaultRuleSet_2.0。 Microsoft_DefaultRuleSet_1.1 是 Azure Front Door 傳統層目前的 DRS。 在 [受控規則] 頁面,選取 [指派] 以指派不同的 DRS。

若要停用個別規則,請選取規則編號前面的核取方塊,然後選取頁面頂端的 [停用]。 若要變更規則集內個別規則的動作類型,請選取規則編號前面的核取方塊,再選取頁面頂端的 [變更動作]

Screenshot that shows the Managed rules page showing a rule set, rule groups, rules, and Enable, Disable, and Change Action buttons.

注意

僅 Azure Front Door 進階層和 Azure Front Door 傳統層原則支援受控規則。

清除資源

當不再需要資源時,請刪除資源群組及所有相關資源。

下一步