Fork me on GitHub

nginx使用certbot配置https

一般现在的网站都要支持https,即安全的http。

机器:阿里云Ubuntu 16.04.3 LTS

 

方案一:自己申请证书

 

配置时需要确保有ssl模块,

之后域名解析下,

之后时申请证书,可以去阿里云上去申请。申请完成之后,把证书下载下来。

再之后配置nginx文件。

参考文章: Nginx如何配置HTTPS

                nginx配置ssl证书实现https

 

方案二:使用certbot

  1.先准备下nginx配置,域名在阿里云上解析过了 ,此时不是https连接。   

server {
  listen 80;
  server_name abc.fisjxlsi.top;
  charset utf-8;
  client_max_body_size 10m;
  location / {
    root /etc/nginx/sites-available;
    index index.html;
  }
}

  

      

 

 

 

 

     

      2.先Certbot官方网站下载 certbot-auto 指令,并设定其执行权限       

sudo wget https://dl.eff.org/certbot-auto
sudo chmod a+x certbot-auto

 

3. 使用certbot-auto ,生成域名证书  

sudo ./certbot-auto 或sudo ./certbot-auto --nginx
之后按提示输入域名,
之后输入1,表示不强制刷新
sudo nginx -t
sudo nginx -s reload

      

       

 

 

    4.证书是90的使用期限,通过下面命令自动更新;

 sudo ./certbot-auto renew

 

       参考文章:Nginx使用免费的HTTPS证书

        Nginx泛域名添加https免费SSL证书Let's Encrypt(certbot)安装使用步骤

                      使用certbot让nginx支持https!

                      nginx配置https服务

 

 

                      

 

posted @ 2019-01-25 10:05  神雕爱大侠  阅读(1526)  评论(0编辑  收藏  举报