为blog配置CloudFlare CDN加速,并为OpenWrt配置ddns

一、配置wordpress域名
在wordpress后台配置两个域名均为https
这里的前提是blog本身已经支持https,不支持https的情况我没法尝试。推荐Redhat的Openshift

二、配置CloudFlare
1、注册CloudFlare
2、添加根域名
3、确认域名解析信息
4、修改域名的NS服务器到CloudFlare指定的NS服务器
等待DNS服务器修改生效

三、http自动转向https
在CloudFlare后台Page Relues添加规则:
匹配模式为http://domain/*
规则为Always use https

四、下载证书
1、ssh连接OpenWrt路由器
2、opkg install curl
3、mkdir -p /etc/ssl/certs
4、curl http://secure.globalsign.net/cacert/Root-R1.crt -o /etc/ssl/certs/GlobalSign_Root_R1.pem
5、从其它linux系统复制 /etc/ssl/certs/ca-certificates.crt到/etc/ssl/certs目录,作为根证书

五、配置OpenWrt的ddns
1、安装ddns-scripts、ddns-scripts_cloudflare、luci-app-ddns
2、刷新页面,进入Service-Daynamic DNS,删掉myddns_ipv6,编辑myddns_ipv4
3、勾选Enable、IPv4-Address,DDns Service provider选CloudFlare,Hostname/Domain填完全的域名(子域名),Username填注册邮箱地址,Password可以为真实的密码或CloudFlare API token(推荐API Token。API Token可以在My account找到),勾选Use HTTP Secure,下面的Path to CA-Certificate填上面的证书路径:/etc/ssl/certs/GlobalSign_Root_R1.pem

最后配置OpenWrt的ddns是个大麻烦。CloudFlare的api要求使用https,但OpenWrt默认使用http,浏览了这里的讨论,多次尝试,最终发现下载GlobalSign_Root_R1.pem证书后,Use HTTP Secure和Path to CA-Certificate才可见。

如果blog不需要https,一、三步不需要。

参考:
https://dev.openwrt.org/ticket/12500
https://api.cloudflare.com/

This entry was posted in Uncategorised, Uncategorized and tagged , . Bookmark the permalink.

6 Responses to 为blog配置CloudFlare CDN加速,并为OpenWrt配置ddns

  1. 土木坛子 says:

    我的虚拟主机怎么没有这么复杂?

  2. 李阳博客 says:

    你现在用的就是cloudflare?我之前使用的时候感觉速度很慢啊~

  3. Sim says:

    Openshitf第三步之后应该怎设置?还有,用CF证书之后后台登陆的时候会提示重定向循环,只能设置后台SSL为False才能访问,看博主的就没有这个情况,请问应该怎么解决,谢谢

Leave a Reply

Your email address will not be published. Required fields are marked *