Cách đây 2 ngày mình có cấu hình lại blog TBD (Tạp Bút Dạo) chuyển sang LEMP Web Stack của Centminmod
Tại sao lại chuyển từ LEMP stack: Webinoly sang Centminmod ?
- Webinoly là giải pháp đơn giản mang tính “hiệu quả” cho người quản trị VPS có thể cài đặt web server một cách nhanh chóng nhất mà không phát sinh quá nhiều thao tác về mặt hiểu biết hệ thống (tất nhiên cần khả năng đọc / hiểu để giải quyết 1 số lỗi phát sinh từ internet. Tham khảo thêm tại: https://webinoly.com/en/
- Centminmod là Web Stack có tuổi đời cũng khá lâu (2011) và được tập trung vào 2 tiêu chí: tuỳ chỉnh/tối ưu hiệu năng – bảo mật (nâng cao). Việc cấu hình cơ bản không khác các Web Stack tuy nhiên phần chuyên sâu và cũng là thế mạnh của Centmin chính là các phần cấu hình mà chính người quản trị cần có kiến thức cơ bản lẫn chuyên sâu để chủ động tinh chỉnh. Ngoài ra đây là stack được xây dựng bởi 1 người, do đó việc hỗ trợ troubleshoot hầu như cũng sẽ hạn chế hơn. Tham khảo thêm tại: https://centminmod.com/
Tuy nhiên nếu sau khi chuyển sang Centminmod (Centmin) và đang sử dụng Cloudflare thì sẽ bị tình trạng Error 521 nếu đang sử dụng Cloudflare SSL/TLS encryption mode is Full / Full (Strict)

Cách xử lý khá đơn giản được phía Centminmod đưa ra đó là whitelist Real-IP của Cloudflare bằng cách sau
Cách 1: chỉ cần chèn danh sách Cloudflare IP này trong /usr/local/nginx/conf/nginx.conf. Lưu ý: chèn trong vùng http { }
Đối với IPv4
# Cloudflare
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
real_ip_header CF-Connecting-IP;
Đối với IPv6
# Cloudflare
set_real_ip_from 2400:cb00::/32;
set_real_ip_from 2405:8100::/32;
set_real_ip_from 2405:b500::/32;
set_real_ip_from 2606:4700::/32;
set_real_ip_from 2803:f800::/32;
set_real_ip_from 2c0f:f248::/32;
set_real_ip_from 2a06:98c0::/29;
real_ip_header CF-Connecting-IP;
Nếu gộp IPv4 và IPv6 chung thì
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
#set_real_ip_from 2400:cb00::/32;
#set_real_ip_from 2405:8100::/32;
#set_real_ip_from 2405:b500::/32;
#set_real_ip_from 2606:4700::/32;
#set_real_ip_from 2803:f800::/32;
#set_real_ip_from 2c0f:f248::/32;
#set_real_ip_from 2a06:98c0::/29;
real_ip_header CF-Connecting-IP;
Cách 2: Tạo 1 file csfips.conf với nội dung sau
#Cloudflare
set_real_ip_from 103.21.244.0/22;
set_real_ip_from 103.22.200.0/22;
set_real_ip_from 103.31.4.0/22;
set_real_ip_from 104.16.0.0/12;
set_real_ip_from 108.162.192.0/18;
set_real_ip_from 131.0.72.0/22;
set_real_ip_from 141.101.64.0/18;
set_real_ip_from 162.158.0.0/15;
set_real_ip_from 172.64.0.0/13;
set_real_ip_from 173.245.48.0/20;
set_real_ip_from 188.114.96.0/20;
set_real_ip_from 190.93.240.0/20;
set_real_ip_from 197.234.240.0/22;
set_real_ip_from 198.41.128.0/17;
#set_real_ip_from 2400:cb00::/32;
#set_real_ip_from 2405:8100::/32;
#set_real_ip_from 2405:b500::/32;
#set_real_ip_from 2606:4700::/32;
#set_real_ip_from 2803:f800::/32;
#set_real_ip_from 2c0f:f248::/32;
#set_real_ip_from 2a06:98c0::/29;
real_ip_header CF-Connecting-IP;
và upload file theo đường dẫn /usr/local/nginx/conf/csfips.conf
Sau đó, mở file /usr/local/nginx/conf/nginx.conf. Lưu ý: chèn trong vùng http { }
http {
include /usr/local/nginx/conf/csfips.conf;
index index.php index.html index.htm;
include mime.types;
default_type application/octet-stream;
Lưu lại và chạy lệnh restart service
ngxrestart