原谅我当一次标题党 python
网站为何要配置 HTTPS,以及配置 HTTPS 有什么优势就再也不解释了,咱们直奔主题,使用 Certbot 工具让你的网站秒配 HTTPS 证书。nginx
Certbot is an easy-to-use client that fetches a certificate from Let’s Encrypt—an open certificate authority launched by the EFF, Mozilla, and others—and deploys it to a web server.
Certbot是由 Let’s Encrypt 一个开放免费证书颁发机构的EFF、Mozilla和其余开发者推出的,易于客户端获取网站加密证书。 自嘲:英语翻译的好烂(^o^)web
PS: 由于测试服务器站点过多,每次使用 acme-tiny 脚本配置证书都要十多分钟时间,为了提升效率,就使用了 Let's Encrypt 官网推荐的自动部署脚本。服务器
官方网站: https://certbot.eff.orgsession
$ sudo apt-get update $ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:certbot/certbot $ sudo apt-get update $ sudo apt-get install python-certbot-nginx
安装成功以后把 certbot
加入系统全局变量 PATH 中。dom
service nginx stop工具
certbot certonly --standalone --email your@email.com -d yourdomain.com测试
一次生成多域名证书:fetch
certbot certonly --standalone --email your@email.com -d yourdomain.com -d yourdomain2.com网站
证书配置成功后提示:
4.查看网站生成的证书
tree /etc/letsencrypt/live/
5.配置 Nginx
…… 其余配置 listen 443 ssl; ssl_certificate /etc/letsencrypt/live/{yourdomain}.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/{yourdomain}.com/privkey.pem; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on;
6.重启 Nginx
service nginx start
此时再加上 https://
访问你的网站,就会有一把可爱别致的小绿锁 Secure
^_^
Let’s Encrypt 生成的免费证书为3个月时间,使用 certbot renew
能够无限免费续签 Https 证书
certbot renew
这是由于 nginx 服务没有关闭,执行 service nginx stop
便可。
以为有用是否是该点赞呢?