3 – Configure HTTPS settings Configure HTTPS settings
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.
← Danh mục ← CatalogGiả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 «3 – Configure HTTPS settings» 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 3 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.
This tutorial shows how to enable TLS 1.3, Automatic HTTPS Rewrites, and Strict SSL mode using the updated v5 provider.
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. This is a summary on Orange Cloud Learning Hub — it does not replace the official documentation.
- 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 đủ. Open the Official docs link below for CLI commands, code snippets, and full screenshots.
- Kiểm tra token/API và state backend trước khi chạy trên môi trường production. Verify API tokens and the state backend before running against 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. Cloudflare docs change frequently — verify the Last reviewed date on the official page before production use.
Tổng quan 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.
After setting up basic DNS records, you can configure zone settings using Terraform. This tutorial shows how to enable TLS 1.3, Automatic HTTPS Rewrites, and Strict SSL mode using the updated v5 provider.
Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)
Yêu cầu trước Prerequisites
Phần «Yêu cầu trước» — đọ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 "Prerequisites" section below — open the official docs link for full screenshots and configuration tabs.
- Completed tutorials 1 and 2
- Valid SSL certificate on your origin server (use the Cloudflare Origin CA to generate one for strict SSL mode)
Terraform code snippets below refer to the v5 SDK only.
Liên kết liên quan (docs Cloudflare) Related links (Cloudflare docs)
1. Tạo zone setting configuration 1. Create zone setting configuration
Tạo new branch and add zone settings:
Read the "1. Create zone setting configuration" section below — open the official docs link for full screenshots and configuration tabs.
Create a new branch and add zone settings:
Terminal window
git checkout -b step3-zone-settings Add the following to your main.tf file:
# Enable TLS 1.3
resource "cloudflare_zone_setting" "tls_1_3" {
zone_id = var.zone_id
setting_id = "tls_1_3"
value = "on"
}
# Enable automatic HTTPS rewrites
resource "cloudflare_zone_setting" "automatic_https_rewrites" {
zone_id = var.zone_id
setting_id = "automatic_https_rewrites"
value = "on"
}
# Set SSL mode to strict
resource "cloudflare_zone_setting" "ssl" {
zone_id = var.zone_id
setting_id = "ssl"
value = "strict"
} 2. Preview và apply changes 2. Preview and apply the changes
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.
Review the proposed changes:
Terminal window
terraform plan Expected output
Plan: 3 to add, 0 to change, 0 to destroy.
Terraform will perform the following actions:
# cloudflare_zone_setting.automatic_https_rewrites will be created
+ resource "cloudflare_zone_setting" "automatic_https_rewrites" {
+ setting_id = "automatic_https_rewrites"
+ value = "on"
+ zone_id = "your-zone-id"
}
# cloudflare_zone_setting.ssl will be created
+ resource "cloudflare_zone_setting" "ssl" {
+ setting_id = "ssl"
+ value = "strict"
+ zone_id = "your-zone-id"
}
# cloudflare_zone_setting.tls_1_3 will be created
+ resource "cloudflare_zone_setting" "tls_1_3" {
+ setting_id = "tls_1_3"
+ value = "on"
+ zone_id = "your-zone-id"
} Commit and merge the changes:
Terminal window
git add main.tf
git commit -m "Step 3 - Enable TLS 1.3, automatic HTTPS rewrites, and strict SSL"
git checkout main
git merge step3-zone-settings
git push Before applying the changes, try to connect with TLS 1.3\. Technically, you should not be able to with default settings. To follow along with this test, you will need to compile curl against BoringSSL ↗.
Terminal window
curl -v --tlsv1.3 https://www.example.com 2>&1 | grep "SSL connection\|error" As shown above, you should receive an error because TLS 1.3 is not yet enabled on your zone. Enable it by running terraform apply and try again.
Apply the configuration:
Terminal window
terraform apply Type yes when prompted.
3. Xác minh settings 3. Verify the settings
Phần «Xác minh settings» — đọ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 the settings" section below — open the official docs link for full screenshots and configuration tabs.
Try the same command as before. The command will now succeed.
Terminal window
curl -v --tlsv1.3 https://www.example.com 2>&1 | grep "SSL connection\|error" {"@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/configure-https-settings/","name":"3 – Configure HTTPS settings"}}]} 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).
Tài liệu gốc ↗ Official docs ↗