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


 


相关内容

热门资讯

浏阳烟花厂爆炸事故是如何发生的... 2026年5月4日下午,湖南长沙浏阳市华盛烟花制造燃放有限公司车间发生爆炸,造成重大人员伤亡,湖南省...
新质生产力企业组团入琼 加速布... 海口5月9日电 (记者 符宇群)“我们希望将公司海洋具身智能技术,与海南得天独厚的海域资源进行深度场...
碳讨|AI涌入电力系统:谁在积... 当新能源装机不断逼近火电,“人工智能+电力”正从概念走向现实。 五大发电集团年报显示,清洁能源装机仍...
继德国后,特朗普瞄准意大利 新华社罗马5月9日电(记者王奕涵 刁泽) 据意大利媒体9日报道,美国总统特朗普接受意《晚邮报》电话采...
看人下菜碟,中国绝不当冤大头 2026年世界杯开赛在即,国际足联(FIFA)却向中国“狮子大开口”,要求支付巨额转播费用。国际足联...
特朗普还有一场硬仗 新华社北京5月9日电 美国民主、共和两党当前正推动有利本党的国会选区重划,并为此大打官司。弗吉尼亚州...
美国佛州发生疑似船只爆炸事故,... 当地时间5月9日,总台记者获悉,美国佛罗里达州迈阿密海滩附近一处热门水上聚会区域发生疑似船只爆炸事故...
【快看】涉及手机、电脑、电视等... 工业和信息化部、商务部、市场监管总局等部门近日联合启动实施《人工智能终端智能化分级》系列国家标准。 ...
中锂电取得锂电池安全保护装置专... 国家知识产权局信息显示,浙江中锂电科技有限公司取得一项名为“一种锂电池安全保护装置”的专利,授权公告...
奥特曼“官宣” OpenAI ... 文 | AI唱反调 今早,奥特曼发布了一条 X,几乎坐实了近半个月来的传闻。 X正文只有三个词:“...