• 申请Let's Encrypt永久免费SSL证书


    申请Let's Encrypt永久免费SSL证书

    Let's Encrypt简介

    Let's Encrypt作为一个公共且免费SSL的项目逐渐被广大用户传播和使用,是由Mozilla、Cisco、Akamai、IdenTrust、EFF等组织人员发起,主要的目的也是为了推进网站从HTTP向HTTPS过度的进程,目前已经有越来越多的商家加入和赞助支持。

    Let's Encrypt免费SSL证书的出现,也会对传统提供付费SSL证书服务的商家有不小的打击。到目前为止,Let's Encrypt获得IdenTrust交叉签名,这就是说可以应用且支持包括FireFox、Chrome在内的主流浏览器的兼容和支持,虽然目前是公测阶段,但是也有不少的用户在自有网站项目中正式使用起来。

    步骤如下:

    第一、安装Let's Encrypt前的准备工作

    #检查系统是否安装git,如果已经自带有git会出现git版本号,没有则需要我们自己安装
    git  --version 
    #git 安装
    yum install git
    #检查Python的版本是否在2.7以上
    python -v //2.6版本
    #安装python所需的包
    yum install zlib-devel
    yum install bzip2-devel
    yum install openssl-devel
    yum install ncurses-devel
    yum install sqlite-devel
    #获取到Python
    cd /usr/local/src
    wget https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz
    #解压Python2.7.12
    tar -zxvf Python-2.7.12.tar.xz
    #编译python
    cd Python-2.7.12/
    ./configure --prefix=/usr/local/python2.7
    make && make install
    #建立链接
    ln -s /usr/local/python2.7/bin/python2.7 /usr/local/bin/python
    #解决系统 Python 软链接指向 Python2.7 版本后,因为yum是不兼容 Python 2.7的,所需要指定 yum 的Python版本
    # vi /usr/bin/yum 
    将头部的
    #!/usr/bin/python
    改成
    #!/usr/bin/python2.6.6
    

    第二、获取Let's Encrypt免费SSL证书

    #获取letsencrypt
    git clone https://github.com/letsencrypt/letsencrypt
    #进入letsencrypt目录
    cd letsencrypt
    #生成证书
    ./letsencrypt-auto certonly --standalone --email quiniton@163.com -d zhaoheqiang.me -d www.zhaoheqiang.me
    

    第三、Let's Encrypt免费SSL证书获取与应用

    在完成Let's Encrypt证书的生成之后,我们会在"/etc/letsencrypt/live/zhaoheqiang.me/"域名目录下有4个文件就是生成的密钥证书文件。

    cert.pem - Apache服务器端证书
    chain.pem - Apache根证书和中继证书
    fullchain.pem - Nginx所需要ssl_certificate文件
    privkey.pem - 安全证书KEY文件

    如果我们使用的Nginx环境,那就需要用到fullchain.pem和privkey.pem两个证书文件,在部署Nginx的时候需要用到。在Nginx环境中,只要将对应的ssl_certificate和ssl_certificate_key路径设置成我们生成的2个文件就可以。

    #打开linux配置文件,找到HTTPS 443端口配置的server
     ssl_certificate /etc/letsencrypt/live/zhaoheqiang.me/fullchain.pem;
     ssl_certificate_key /etc/letsencrypt/live/zhaoheqiang.me/privkey.pem;
    

    第四、解决Let's Encrypt免费SSL证书有效期问题

    Let's Encrypt证书是有效期90天的,需要我们自己手工更新续期才可以。
    命令如下:

     ./letsencrypt-auto certonly --renew-by-default --email quiniton@163.com -d zhaoheqiang.me -d www.zhaoheqiang.me


    upstream tomcat-lb {
    server 127.0.0.1:10080;
    }

    server{

    listen 80;
    server_name git.cheyunhua.top;

    return 301 https://$server_name$request_uri;
    }
    server
    {
    listen 443 ssl;
    ssl on;
    server_name git.cheyunhua.top;
    index index.html index.htm index.jsp;
    ssl_certificate cert/cert1.pem;
    ssl_certificate_key cert/privkey1.pem;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HICH:+MEDIUM:!LOW:!aNULL:!eNULL;
    access_log /app/log/nginx/git.log;
    error_log /app/log/nginx/error_git.log;


    location / {
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto $scheme;
    proxy_pass http://tomcat-lb;
    }

    }

     


    作者:StrongZhao
    链接:https://www.jianshu.com/p/3ae2f024c291
    來源:简书
    简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。
  • 相关阅读:
    ubuntu下在apache部署python站点
    MySQL设置从库只读模式
    mysql数据库,创建只读用户
    BUG处理流程说明
    bug的处理流程
    nginx 502 Bad Gateway 错误解决办法
    Linux下批量替换文件内容方法
    centos 安装pecl
    php学习资源
    Docker容器进入的4种方式(转)
  • 原文地址:https://www.cnblogs.com/cheyunhua/p/9413935.html
Copyright © 2020-2023  润新知