Tutorial Tutorial Tutorial Application Services Application Services Application Services ~32 phút ~32 min ~32 នាទី Đồng bộ 2026-06-10 Synced 2026-06-10 ធ្វើសមកាល 2026-06-10

Thêm ngoại lệ với Page Rules Add exceptions with Page Rules បន្ថែមករណីលើកលែងជាមួយ Page Rules

Hướng dẫn chi tiết đồng bộ từ docs Cloudflare — mỗi section có backlink tới đúng vị trí trên trang gốc. Detailed guide synced from Cloudflare docs — each section links to the matching anchor on the official page. មគ្គុទ្ទេសក៍លម្អិតធ្វើសមកាលពី docs Cloudflare — ផ្នែកនីមួយៗមានតំណទៅទីតាំងត្រូវគ្នានៅទំព័រផ្លូវការ។

← Danh mục ← Catalog ← បញ្ជី

Giải thích nhanh Quick context បរិបទរហ័ស

Thuộc nhóm Application Services — tập trung bảo vệ, tăng tốc và vận hành ứng dụng/web phía trước origin. Tutorial «5 – Add exceptions với Page Rules» giúp bạn làm quen luồng triển khai thật — phù hợp đọc trước khi mở tài liệu gốc tiếng Anh. Docs gốc chia khoảng 4 bước chính; bản tóm tắt dưới đây giúp bạn nắm khung trước khi làm theo từng lệnh.

Page Rules let you override zone settings for specific URL patterns. Redirects old URLs with a 301 permanent redirect.

Page Rules អនុញ្ញាតឱ្យអ្នកបដិសេធការកំណត់តំបន់សម្រាប់លំនាំ URL ជាក់លាក់។ បញ្ជូនបន្ត URLs ចាស់ជាមួយនឹង 301 ប្តូរទិសអចិន្ត្រៃយ៍។

Lưu ý Note ចំណាំ

Lưu ý trước khi làm Notes before you start ចំណាំមុនពេលចាប់ផ្តើម

  • Đây là bản tóm tắt trên Orange Cloud Learning Hub — không thay thế tài liệu chính thức.
  • Luôn mở liên kết «Tài liệu gốc» bên dưới khi cần lệnh CLI, snippet code và ảnh minh họa đầy đủ.
  • Kiểm tra token/API và state backend trước khi chạy trên môi trường production.
  • Docs Cloudflare cập nhật thường xuyên — đối chiếu ngày «Rà soát lần cuối» trên trang gốc khi triển khai production.
  • This is a summary on Orange Cloud Learning Hub — it does not replace the official documentation.
  • Open the Official docs link below for CLI commands, code snippets, and full screenshots.
  • Verify API tokens and the state backend before running against production.
  • Cloudflare docs change frequently — verify the Last reviewed date on the official page before production use.
  • នេះគឺជាការសង្ខេបនៅលើ Orange Cloud Learning Hub — វាមិនជំនួសឯកសារផ្លូវការទេ។
  • បើកតំណឯកសារផ្លូវការខាងក្រោមសម្រាប់ពាក្យបញ្ជា CLI កូដ snippets និងរូបថតអេក្រង់ពេញ។
  • ផ្ទៀងផ្ទាត់ API សញ្ញាសម្ងាត់ និងផ្នែកខាងក្រោយរបស់រដ្ឋ មុនពេលដំណើរការប្រឆាំងនឹងការផលិត។
  • Cloudflare ឯកសារផ្លាស់ប្តូរជាញឹកញាប់ — ផ្ទៀងផ្ទាត់កាលបរិច្ឆេទដែលបានពិនិត្យចុងក្រោយនៅលើទំព័រផ្លូវការមុនពេលប្រើប្រាស់ផលិតកម្ម។

Overview Overview ទិដ្ឋភាពទូទៅ

Phần «Tổng quan» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "Overview" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «ទិដ្ឋភាពទូទៅ» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Trong hướng dẫn Configure HTTPS settings, bạn đã cấu hình cài đặt khu vực áp dụng cho tất cả các yêu cầu đến cho example.com. Trong hướng dẫn này, bạn sẽ thêm một ngoại lệ vào các cài đặt này bằng cách sử dụng Page Rules.
In the Configure HTTPS settings tutorial, you configured zone settings that apply to all incoming requests for example.com. In this tutorial, you will add an exception to these settings using Page Rules.
Cụ thể, bạn sẽ tăng mức độ bảo mật cho một URL được biết là tốn kém để hiển thị và không thể được lưu trữ trong bộ nhớ cache: https://www.example.com/expensive-db-call. Ngoài ra, bạn sẽ thêm một chuyển hướng từ URL trước đó được sử dụng để lưu trữ trang này.
Specifically, you will increase the security level for a URL known to be expensive to render and cannot be cached: https://www.example.com/expensive-db-call. Additionally, you will add a redirect from the previous URL used to host this page.
ជា​ពិសេស អ្នក​នឹង​បង្កើន​កម្រិត​សុវត្ថិភាព​សម្រាប់ URL ដែល​គេ​ដឹង​ថា​មាន​តម្លៃ​ថ្លៃ​ក្នុង​ការ​បង្ហាញ និង​មិន​អាច​ត្រូវ​បាន​ទុក​ក្នុង​ឃ្លាំង​សម្ងាត់៖ https://www.example.com/expensive-db-call។ លើសពីនេះ អ្នកនឹងបន្ថែមការបញ្ជូនបន្តពី URL ពីមុនដែលធ្លាប់ធ្វើជាម្ចាស់ផ្ទះទំព័រនេះ។
Các đoạn mã Terraform dưới đây chỉ đề cập đến v5 SDK.
Terraform code snippets below refer to the v5 SDK only.
កូដ Terraform snippets ខាងក្រោមសំដៅលើ v5 SDK ប៉ុណ្ណោះ។

Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs) តំណពាក់ព័ន្ធ (docs Cloudflare)

1.Điều Tạo Page Rules cấu hình 1. Create Page Rules configuration 1. បង្កើតការកំណត់រចនាសម្ព័ន្ធ Page Rules

Tạo new branch and append the configuration.

Read the "1. Create Page Rules configuration" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «1. បង្កើតការកំណត់រចនាសម្ព័ន្ធ Page Rules» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Tạo một nhánh mới và đính kèm cấu hình.
Create a new branch and append the configuration.
បង្កើតសាខាថ្មី ហើយបន្ថែមការកំណត់រចនាសម្ព័ន្ធ។
Cửa sổ Terminal
Terminal window
បង្អួចស្ថានីយ
text
git checkout -b step5-pagerule
Page Rules cho phép bạn bỏ qua cài đặt khu vực cho các mẫu URL cụ thể. Thêm hai Page Rules vào main.tf của bạn:
Page Rules let you override zone settings for specific URL patterns. Add two Page Rules to your main.tf:
Page Rules អនុញ្ញាតឱ្យអ្នកបដិសេធការកំណត់តំបន់សម្រាប់លំនាំ URL ជាក់លាក់។ បន្ថែម Page Rules ពីរទៅ main.tf របស់អ្នក៖
text
# Increase security for expensive database operations

resource "cloudflare_page_rule" "expensive_endpoint_security" {

  zone_id  = var.zone_id

  target   = "${var.domain}/expensive-db-call"

  priority = 1


  actions = {

    security_level = "under_attack"

  }

}


# Redirect old URLs to new location

resource "cloudflare_page_rule" "legacy_redirect" {

  zone_id  = var.zone_id

  target   = "${var.domain}/old-location.php"

  priority = 2


  actions = {

    forwarding_url = {

      url         = "https://www.${var.domain}/expensive-db-call"

      status_code = 301

    }

  }

}
Quy tắc đầu tiên làm tăng bảo mật cho "Dưới chế độ tấn công" cho điểm cuối cơ sở dữ liệu của bạn. Quy tắc thứ hai chuyển hướng các URL cũ với một chuyển hướng vĩnh viễn 301.
The first rule increases security to "Under Attack" mode for your database endpoint. The second rule redirects old URLs with a 301 permanent redirect.
ច្បាប់ទីមួយបង្កើនសុវត្ថិភាពទៅរបៀប "ក្រោមការវាយប្រហារ" សម្រាប់ចំណុចបញ្ចប់នៃមូលដ្ឋានទិន្នន័យរបស់អ្នក។ ច្បាប់ទីពីរបញ្ជូនបន្ត URLs ចាស់ជាមួយនឹង 301 ប្តូរទិសអចិន្ត្រៃយ៍។

2.Đối với Xem trước và áp dụng các thay đổi: 2. Preview and apply the changes: 2. មើលជាមុន និងអនុវត្តការផ្លាស់ប្តូរ៖

Phần «Preview và apply changes:» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "2. Preview and apply the changes:" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «2. មើលជាមុន និងអនុវត្តការផ្លាស់ប្តូរ៖» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Cửa sổ Terminal
Terminal window
បង្អួចស្ថានីយ
text
terraform plan

terraform apply

3 Cái Kiểm tra thay đổi: 3. Verify changes: 3. ផ្ទៀងផ្ទាត់ការផ្លាស់ប្តូរ៖

Phần «Xác minh changes:» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "3. Verify changes:" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «3. ផ្ទៀងផ្ទាត់ការផ្លាស់ប្តូរ៖» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Kiểm tra chức năng chuyển hướng:
Test the redirect functionality:
សាកល្បងមុខងារបញ្ជូនបន្ត៖
Cửa sổ Terminal
Terminal window
បង្អួចស្ថានីយ
text
curl -I https://example.com/old-location.php
Kết quả dự kiến:
Expected output:
ទិន្នផលរំពឹងទុក៖
text
HTTP/1.1 301 Moved Permanently

Location: https://example.com/expensive-db-call
Kiểm tra bảo mật tăng cường (Trong chế độ tấn công trả về một trang thách thức):
Test the increased security (Under Attack mode returns a challenge page):
សាកល្បង​សុវត្ថិភាព​ដែល​បាន​កើន​ឡើង (ក្រោម​របៀប​វាយ​ប្រហារ​ត្រឡប់​ទំព័រ​បញ្ហា)៖
Cửa sổ Terminal
Terminal window
បង្អួចស្ថានីយ
text
curl -I https://example.com/expensive-db-call
Kết quả dự kiến:
Expected output:
ទិន្នផលរំពឹងទុក៖
text
HTTP/1.1 503 Service Temporarily Unavailable
Trả lời 503 cho biết chế độ Under Attack đang hoạt động, trình bày cho khách truy cập một trang thách thức trước khi cho phép access để bảo vệ chống lại các cuộc tấn công DDoS.
The 503 response indicates the Under Attack mode is active, presenting visitors with a challenge page before allowing access to protect against DDoS attacks.
ការឆ្លើយតប 503 បង្ហាញថា Under Attack mode គឺសកម្ម បង្ហាញអ្នកទស្សនាជាមួយនឹងទំព័រប្រឈម មុនពេលអនុញ្ញាតឱ្យ access ការពារប្រឆាំងនឹង DDoS ការវាយប្រហារ។

Bốn Cam kết và kết hợp các thay đổi: 4. Commit and merge the changes: 4. ប្តេជ្ញា និងបញ្ចូលការផ្លាស់ប្តូរ៖

Phần «Commit và merge changes:» — đọc hướng dẫn bên dưới, dùng liên kết docs gốc để xem ảnh minh họa và tab cấu hình đầy đủ.

Read the "4. Commit and merge the changes:" section below — open the official docs link for full screenshots and configuration tabs.

អានផ្នែក «4. ប្តេជ្ញា និងបញ្ចូលការផ្លាស់ប្តូរ៖» ខាងក្រោម — បើកតំណ docs ផ្លូវការសម្រាប់រូបភាព និង tab កំណត់។

Mở section docs gốc ↗ Open source section ↗ បើកផ្នែក docs ផ្លូវការ ↗
Cửa sổ Terminal
Terminal window
បង្អួចស្ថានីយ
text
git add main.tf

git commit -m "Step 5 - Add two Page Rules"

git push
Cuộc gọi hoạt động như mong đợi. Trong trường hợp đầu tiên, mạng toàn cầu Cloudflare phản ứng với một 301 chuyển hướng trình duyệt đến vị trí mới. Trong trường hợp thứ hai, mạng toàn cầu Cloudflare ban đầu phản ứng với 503, phù hợp với chế độ Under Attack.
The call works as expected. In the first case, the Cloudflare global network responds with a 301 redirecting the browser to the new location. In the second case, the Cloudflare global network initially responds with a 503, which is consistent with the Under Attack mode.
ការហៅទូរស័ព្ទដំណើរការដូចការរំពឹងទុក។ ក្នុងករណីដំបូង បណ្តាញសកល Cloudflare ឆ្លើយតបដោយ 301 បញ្ជូនបន្តកម្មវិធីរុករកតាមអ៊ីនធឺណិតទៅទីតាំងថ្មី។ ក្នុងករណីទី 2 បណ្តាញសកល Cloudflare ដំបូងឆ្លើយតបជាមួយ 503 ដែលស្របនឹងរបៀបវាយប្រហារក្រោម។
json
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"item":{"@id":"/directory/","name":"Directory"}},{"@type":"ListItem","position":2,"item":{"@id":"/terraform/","name":"Terraform"}},{"@type":"ListItem","position":3,"item":{"@id":"/terraform/tutorial/","name":"Tutorials"}},{"@type":"ListItem","position":4,"item":{"@id":"/terraform/tutorial/add-page-rules/","name":"5 – Add exceptions with Page Rules"}}]}

Xem bản đầy đủ trên developers.cloudflare.com (ảnh, tab cấu hình). View the full guide on developers.cloudflare.com (images, config tabs). មើលមគ្គុទ្ទេសក៍ពេញលើ developers.cloudflare.com (រូបភាព, tab កំណត់)។

Tài liệu gốc ↗ Official docs ↗ ឯកសារផ្លូវការ ↗