OpenWR配置安装SSL证书

发布时间:2021/1/16 10:14:20 打印 字号:

一、登录邮箱下载:Gworg证书文件目录 ,都会有以下五个文件夹。OpenWR只需要用到nginx文件夹。

Gworg证书文件目录

二、

文件位置

/etc/config/uhttpd

文件内容

config uhttpd 'main'
    list listen_http '0.0.0.0:80'
    list listen_http '[::]:80'
    list listen_proxy '127.0.0.1:8000'
    list listen_https '0.0.0.0:443'
    list listen_https '[::]:443'
    option home '/www'
    option rfc1918_filter '0'
    option max_requests '3'
    option max_connections '100'
    option cert '/etc/config/uhttpd.crt'
    option key '/etc/config/uhttpd.key'
    option cgi_prefix '/cgi-bin'
    list lua_prefix '/cgi-bin/luci=/usr/lib/lua/luci/sgi/uhttpd.lua'
    option script_timeout '60'
    option network_timeout '30'
    option http_keepalive '20'
    option tcp_keepalive '1'
    list index_page 'cgi-bin/luci'
    option ubus_prefix '/ubus'

config cert 'defaults'
    option days '730'
    option bits '2048'
    option country 'ZZ'
    option state 'Somewhere'
    option location 'Unknown'
    option commonname 'Openwrt Koolshare mod'

修改端口

使用vi编辑

    list listen_http '0.0.0.0:80'       #ipv4http端口80
    list listen_http '[::]:80'          #ipv6http端口80
    list listen_proxy '127.0.0.1:8000'  #代理端口8000
    list listen_https '0.0.0.0:443'     #ipv4https端口443
    list listen_https '[::]:443'        #ipv6https端口443

以上几个按需修改

开启HTTPS

首先上传域名证书,比如上传上/etc/config/目录
编辑此处指向证书

    option cert '/etc/config/uhttpd.crt'
    option key '/etc/config/uhttpd.key'

最后

重启uhttpd服务

/etc/init.d/uhttpd restart

其他

如不成功请在软件包内检查是否已安装openssl



其它教程

一、安装依赖包

#软件名

luci-app-uhttpd                          

luci-i18n-uhttpd-zh-cn    

luci-ssl-openssl


二、把Gworg的证书Nginx格式保存到本地(server.key,server.crt)

######################################################

不通过页面ui改证书可以直接修改/etc/config/uhttpd这个文件的

option cert '/etc/server.crt'#证书在软路由上的具体位置

option key '/etc/server.key'#秘钥在软路由上的具体位置

确认好这两个文件要有读的权限

image.png


三、 重启uhttpd服务

service uhttpd restart


补充说明帮助

页面打不开的解决办法: 

我保证我写这篇文章的时候,按照我写的步骤正确配置是可以成功打开页面的,只是有些应用不支持https可能没办法正常使用.

        1. 清空浏览器缓存再试试

        2. 重启下uhttpd服务: /etc/init.d/uhttpd restart

        3. 重启下软路由系统

页面打不开的还原办法: 

页面可以打开的情况下取消https只需要点击上图删除证书和密钥的配置  然后  保存应用

vi /etc/config/uhttpd

把文件中 config uhttpd 'main' 下的option cert和option key 开头的这两行直接删掉

#这行千万不要删
config uhttpd 'main'
        option cert '/etc/uhttpd.crt'#删这行
        option key '/etc/uhttpd.key'#删这行

然后重启下uhttpd服务

/etc/init.d/uhttpd restart

还打不开就重启下系统,删除下浏览器的缓存