温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

在你的网站服务器配置https

发布时间:2020-07-02 09:18:37 来源:网络 阅读:670 作者:CzlunSu 栏目:建站服务器

在你的网站服务器配置https

简介

通过Let's Encrypt免费提供的证书服务,实现http使用ssl进行加密传输(https://zh.wikipedia.org/wiki/%E5%82%B3%E8%BC%B8%E5%B1%A4%E5%AE%89%E5%85%A8%E5%8D%94%E8%AD%B0),让你的网站更安全。

 

Let's Encrypt

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

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

 

操作环境如下

[root@www ~]# cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

[root@www ~]# nginx -V

nginx version: nginx/1.12.0

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)

built with OpenSSL 1.0.1e-fips 11 Feb 2013

TLS SNI support enabled

configure arguments: --user=nginx --group=nginx --prefix=/application/nginx-1.12.0/ --with-http_v2_module --with-http_ssl_module --with-http_sub_module --with-http_stub_status_module --with-http_gzip_static_module --with-pcre

 

安装certbot

yum安装certbot

启用EPEL仓库

[root@www ~]# yum install -y yum-utils

[root@www~] # yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional

安装certbot

[root@www~] # sudo yum install certbot

 

git安装certbot

安装git工具:

安装依赖:

[root@www ~]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

下载源码:

[root@www ~]# wget https://github.com/git/git/archive/v2.13.0.tar.gz

编译安装git

[root@www ~]# tar -zxf git-2.13.0.tar.gz

[root@www ~]# cd git-2.13.0

[root@www git-2.13.0]# make prefix=/usr/local all

[root@www git-2.13.0]# make prefix=/usr/local install

更新python至2.7以上:

检查python版本

[root@www git-2.13.0]# python -V

Python 2.4.3

安装gcc编译器

[root@www ~]# yum -y install gcc

下载python源码

[root@www ~]# wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz

编译安装python2.7

[root@www ~]# tar -zxf Python-2.7.13.tgz

[root@www ~]# cd Python-2.7.13

[root@www ~]#./configure

[root@www ~]# make all

[root@www ~]# make install

[root@www ~]# make clean

[root@www ~]# make distclean

更改python命令指向python2.7

[root@www Python-2.7.13]# mv /usr/bin/python /usr/bin/python2.4

[root@www Python-2.7.13]# ln -s /usr/local/bin/python2.7 /usr/bin/python

[root@www Python-2.7.13]# python -V

Python 2.7.13  #更新成功

安装certbot

[root@www ~]# git clone https://github.com/letsencrypt/letsencrypt

 

获取证书

使用手动的方式获取证书

 

yum安装certbot使用的命名

[root@www ~]# certbot certonly --standalone --email 244819336@qq.com -d czlun.top -d www.czlun.top

git安装certbot使用的命令

[root@www ~]# cd letsencrypt

[root@www letsencrypt]# ./letsencrypt-auto certonly --standalone --email 244819336@qq.com -d czlun.top -d www.czlun.top

244819336@qq.com替换成自己的邮箱

czlun.topwww.czlun.top替换成自己的域名

证书的位置

在对应的域名下有四个生成的密钥证书文件

[root@www ~]# ls /etc/letsencrypt/live/czlun.top/

cert.pem  chain.pem  fullchain.pem  privkey.pem  README

cert.pem - Apache服务器端证书

chain.pem - Apache根证书和中继证书

fullchain.pem - Nginx所需要ssl_certificate文件

privkey.pem - 安全证书KEY文件

 

配置nginx

server{

    listen 80;

    server_name czlun.top www.czlun.top;

    return 301 https://www.czlun.top$request_uri;

}

server {

    listen 443 ssl;

    server_name czlun.top www.czlun.top;

    ssl on;

        ssl_certificate /etc/letsencrypt/live/czlun.top/fullchain.pem;

        ssl_certificate_key /etc/letsencrypt/live/czlun.top/privkey.pem;

    [该域名主机的其他配置在这]

}

 

重启nginx可以看到SSL证书生效,且HTTPS可以访问站点

在你的网站服务器配置https


 


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI