在你的网站服务器配置https
admin
2023-03-17 21:21:20
0

在你的网站服务器配置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


 


相关内容

热门资讯

今日重大消息“微乐家乡大贰辅助... 网上科普关于“微乐家乡大贰有没有挂”话题很是火热,小编也是针对微乐家乡大贰作*弊开挂的方法以及开挂对...
我来教教您“友乐广西麻将到底有... 您好:友乐广西麻将这款游戏可以开挂,确实是有挂的,需要了解加客服微信【9752949】很多玩家在这款...
终于明白“花花生活圈开挂神器?... 网上科普关于“花花生活圈有没有挂”话题很是火热,小编也是针对花花生活圈作*弊开挂的方法以及开挂对应的...
终于了解“AAPOKER到底是... 有 亲,根据资深记者爆料AAPOKER是可以开挂的,确实有挂(咨询软件无...
终于明白“山西互动是不是有挂?... 网上科普关于“山西互动有没有挂”话题很是火热,小编也是针对山西互动作*弊开挂的方法以及开挂对应的知识...
【第一资讯】“推大石怎么装挂?... 有 亲,根据资深记者爆料推大石是可以开挂的,确实有挂(咨询软件无需打开直...
玩家分享攻略“秦乐陕西麻将开挂... 网上科普关于“秦乐陕西麻将有没有挂”话题很是火热,小编也是针对秦乐陕西麻将作*弊开挂的方法以及开挂对...
终于了解“新上游炸/金/花究竟... 网上科普关于“新上游炸/金/花有没有挂”话题很是火热,小编也是针对新上游炸/金/花作*弊开挂的方法以...
终于明白“趣友麻将究竟有挂吗?... 网上科普关于“趣友麻将有没有挂”话题很是火热,小编也是针对趣友麻将作*弊开挂的方法以及开挂对应的知识...
最新引进“至尊宝炸金花开挂器?... 家人们!今天小编来为大家解答至尊宝炸金花透视挂怎么安装这个问题咨询软件客服徽4282891的挂在哪里...