标签:targe target bsp pre share github 免费 hpa str
云服务商:阿里云
服务器:针对Nginx服务器;
假设域名:example.com www.example.com
假设IP:137.137.137.137
1,先安装nginx服务器
sudo apt-get install nginx sudo service nginx start
2,安装letsencrypt
sudo apt-get install letsencrypt
3,签发证书
很简单,直接运行letsencrypt命令即可
sudo letsencrypt certonly --webroot -w /var/www/html -d example.com -d www.example.com
4,git clone项目
首先安装git 和bc ,并从github上将代码克隆到本地
sudo git clone https://github.com/certbot/certbot /opt/certbot-master
5,安装依赖 ---这里指的是centeros
sudo /opt/certbot-master/letsencrypt-auto --help –standalone –email 邮箱地址(邮箱地址是用来接收紧急通知和找回密钥的) –d 域名
中间会出现界面验证你的邮箱地址是否有效
命令完成后,最新版本的证书位置:/etc/letsencrypt/live/域名
cert.pem 申请的服务器证书文件
privkey.pem 服务器证书对应的私钥
chain.pem 除服务器证书外,浏览器解析所需的其他全部证书,比如根证书和中间证书
fullchain.pem 包含服务器证书的全部证书链文件
配置nginx,需要生成dhparam.pem文件
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048
6,在nginx里面配置
一般情况下只需要privkey.pem和fullchain.pem这两个就够了
server { listen 443 ssl; server_name 域名; ssl_certificate /etc/letsencrypt/live/域名/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/域名/privkey.pem; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_ciphers ‘ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA‘; ssl_session_timeout 1d; ssl_session_cache shared:SSL:50m; ssl_stapling on; ssl_stapling_verify on; add_header Strict-Transport-Security max-age=15768000; # The rest of your server block root /path/to/root; index index.html index.htm; location / { try_files $uri $uri/ =404; } }
7,配置完成后
配置完成后重启nginx
在谷歌浏览器中输入域名,谷歌浏览器查看详情
或者通过此网址查询:https://www.ssllabs.com/ssltest/analyze.html?d=域名
8,自动续期
自动续期问题:(注意关闭nginx)输入
./letsencrypt-auto renew 手动续期会发现提示还未到期,无法续期
强制更新续期
./letsencrypt-auto renew --force-renewal
这样的话就显示续期成功
可以写一个脚本,创建个定时任务,定期自动续期。
nginx 配置lets Encrypt永久免费SSL证书过程教程
标签:targe target bsp pre share github 免费 hpa str
原文地址:https://www.cnblogs.com/52forjie/p/9996894.html