主機

How Smart Tools Are Shaping the Future of Creative Work

Eric Chuang
2025-01-23

在社群夥伴勇哥的文章〈Webinoly 最新版快速安裝〉中,提到使用 Webinoly 來建立 WordPress 用的 LEMP 環境時,有時候會有跟 Cloudflare 衝突的情況,尤其在使用 sudo site example.com -ssl=on 的時候。

原本的做法是直接不透過 Cloudflare 的 Proxy 處理流量,但是在一次客戶網站被 DDoS 攻擊後,我發現可能還是要用 Cloudflare 來協助過濾一下一些比較暴力的攻擊模式,所以認真研究了一下讓 Webinoly 跟 Cloudflare 可以和平共處的方法。

結論來說,就是:

  1. Webinoly 在新建網站時,先關閉 wp-admin 的 httpauth:sudo httpauth example.com -wp-admin=off
  2. 在 Cloudflare 上,選擇 [完整 (嚴格)] (英文版的 Full (Strict)) 加密模式
  3. 關閉 Cloudflare 上的 [一律使用 HTTPS] 功能

Cloudflare 的加密模式

Cloudflare 免費版提供了 4 個 SSL/TLS 的加密模式選項,分別是:

  1. 完整 (嚴格) – Full (Strict)
  2. 完整 – Full
  3. 彈性 – Flexible
  4. 關閉 – 不安全

因為我們已經透過 Let’s Encrypt 產生 SSL 憑證,所以透過 [完整 (嚴格)] 的方式加密即可。使用 Flexible 的時候有時會產生 Too Many Redirects 的問題。

原本最早我的做法是直接選 [關閉],但後來基於安全性的考慮,想說最好還是多一端的加密,因此建議還是可以開啟 [完整 (嚴格)]。

Certbot 產生 SSL 的機制

根據 Certbot 的文件,驗證並產生憑證的方法有兩種:

  • 在 example.com 下配置 DNS 記錄。
  • 在 http://example.com/ 的已知 URI 下配置 HTTP 資源。

而從 Webinoly 回傳的系統訊息當中,我們可以看到它預設使用的是第二種方式的驗證方法,因為 DNS 紀錄沒有辦法簡單地從主機端去自動處理。

因此,重點在於要讓 http 的版本可以順利存取,因此關閉 Cloudflare 強制改寫 http 到 https 的功能是必要的。

相關文章

Sign up for our newsletter

Subscribe to our newsletter to receive the latest updates, expert insights, and practical tips directly in your inbox. Stay informed with content designed to help you grow.

+480.000 happy customers

Gain more with expert solutions

Unlock the full potential of your business with our expert solutions. Our team provides tailored strategies, professional guidance, and actionable insights to help you achieve better results.

  • Eric Chuang
  • •
  • 2025-01-23
如何同時使用 Webinoly 與 Cloudflare 保護網站安全

在社群夥伴勇哥的文章〈Webinoly 最新版快速安裝〉中,提到使用 Webinoly 來建立 WordPre […]

主機