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 កំណត់។
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.example.com. In this tutorial, you will add an exception to these settings using Page Rules.example.com។ នៅក្នុងមេរៀននេះ អ្នកនឹងបន្ថែមករណីលើកលែងមួយទៅការកំណត់ទាំងនេះដោយប្រើ Page Rules។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.https://www.example.com/expensive-db-call. Additionally, you will add a redirect from the previous URL used to host this page.https://www.example.com/expensive-db-call។ លើសពីនេះ អ្នកនឹងបន្ថែមការបញ្ជូនបន្តពី URL ពីមុនដែលធ្លាប់ធ្វើជាម្ចាស់ផ្ទះទំព័រនេះ។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 កំណត់។
git checkout -b step5-pagerule main.tf của bạn:main.tf:main.tf របស់អ្នក៖# 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
}
}
} 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 កំណត់។
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 កំណត់។
curl -I https://example.com/old-location.php HTTP/1.1 301 Moved Permanently
Location: https://example.com/expensive-db-call curl -I https://example.com/expensive-db-call HTTP/1.1 503 Service Temporarily Unavailable 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 កំណត់។
git add main.tf
git commit -m "Step 5 - Add two Page Rules"
git push 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.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.301 បញ្ជូនបន្តកម្មវិធីរុករកតាមអ៊ីនធឺណិតទៅទីតាំងថ្មី។ ក្នុងករណីទី 2 បណ្តាញសកល Cloudflare ដំបូងឆ្លើយតបជាមួយ 503 ដែលស្របនឹងរបៀបវាយប្រហារក្រោម។{"@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 ↗ ឯកសារផ្លូវការ ↗