nginx如何防止ssl证书过期


本文摘自PHP中文网,作者藏色散人,侵删。

nginx如何防止ssl证书过期

nginx配置免费SSL证书及证书定时更新

环境 contos 6,证书发行Let's Encrypt

证书生成前提是域名是可用的,即已经备案通过并且有DNS解析到了具体IP

1、安装epel,

1

>yum install epel-release

2、下载certbot证书生成工具certbot-auto

1

>wget https://dl.eff.org/certbot-auto --no-check-certificate

3、安装工具的依赖

1

2

>chmod +x certbot-auto

>./certbot-auto -n

4、生成证书

单域名:

1

>./certbot-auto certonly --email my@163.com --agree-tos --no-eff-email --webroot -w /usr/local/nginx/html/xue/ -d www.xue37.cn

注意:替换邮箱、网站目录和域名

多域名:

1

>./certbot-auto certonly --email my@163.com --agree-tos --no-eff-email --webroot -w /usr/local/nginx/html/xue/ -d www.xue37.cn -d xue37.cn

证书生成在/etc/letsencrypt/live/www.xue37.cn/目录下(具体生成地址执行完命令有提示信息)

5、证书延期(因为证书有效期为90天)

certbot-auto工具支持证书延期操作,因此可以使用crontab定时任务定时自动延期

1

>0 3 * * * /root/certbot-auto renew --disable-hook-validation --renew-hook "/usr/local/nginx/sbin/nginx -s reload"

每天3点进行证书延期,crontab表达式自己可以百度

注意:

自己可以先单独执行一下:

1

/root/certbot-auto renew --disable-hook-validation --renew-hook "/usr/local/nginx/sbin/nginx -s reload"

我这里提示The following certs are not due for renewal yet,表示证书未到期,没有其他错误。因此为了防止证书失效时间过久,这里可以设置为每天都进行延期操作

6、nginx增加证书配置

阅读剩余部分

相关阅读 >>

nginx4层是哪四层

nginx源码是什么语言

nginx可以启动成功却无法访问

nginx和netty区别

linux中关于nginx反向代理下的tomcat集群的详细介绍

403nginx是什么

教你如何在linux中安装nginx服务器

nginx启动的时候提示端口被占用怎么解决

nginx安装后怎么开发

nginx如何解决cookie跨域

更多相关阅读请进入《nginx》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...