参考文章:https://blog.csdn.net/WoTrusCA/article/details/112799120

近期转移网站到家里的软路由上,索性把所有的前端页面改为https访问,配置过程中遇到了不少问题。

证书格式

阿里云提供了多种证书格式,nginx、Apache等,但在配置过程中发现只用nginx格式的就够了。下载解压证书后发现有xxx.key和xxx.pem两个文件。

配置openwrt

1.在任意位置创建两个证书文件,这里以/etc/为例:

vim /etc/xxx.crt  #此文件复制进xxx.pem的内容
vim /etc/xxx.key  #此文件复制进xxx.key的内容

2.编辑uhttpd配置文件:

vim /etc/config/uhttpd

在‘main’下方添加如下内容:

list listen_https '0.0.0.0:443'
list listen_https '[::]:443'
option redirect_https '1'  #强制重定向
option cert '/etc/xxx.crt'
option key '/etc/xxx.key'

3.重启uhttpd服务:

/etc/init.d/uhttpd restart