当前位置:网站首页>SSL证书部署
SSL证书部署
2022-07-06 20:21:00 【不会秃头】
当我们申请完SSL证书后,还需要对nginx进行相关配置,才可以转为安全连接。
下载证书文件到服务器
- 首先,进入服务器控制台,下载证书到本地。


上述截图操作后,我们可以下载证书到本地了。
解压后如图:

其中:.key结尾的文件为密钥文件。.pem结尾的文件为证书文件。
我们需要把这两个文件上传到服务器上。
- 上传本地证书到服务器指定目录
我这里上传到/usr/local/nginx/cert/目录下。
上传后如图:

里面包含了我们的密钥文件和证书文件
好了。这样我们就上传证书到服务器了。
配置nginx.conf
我们还需要配置nginx.conf文件来使证书文件生效。
添加server模块。
在配置文件中添加模块server模块。
一般,默认的配置文件是有这些内容的,只不过被注释掉了。我们放开就好。
但是,也要改些东西。下面已经给出提示。
server {
listen 443 ssl;
server_name localhost;
# 后面的路径是你上一步上传文件的绝对路径。
# 不写绝对路径会报错
ssl_certificate /usr/local/nginx/cert/xxxxxxxx_bundle.pem;
ssl_certificate_key /usr/local/nginx/cert/xxxxxxxx.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}
nginx添加ssl模块
- 查看我们目前安装了哪些模块
/usr/local/ngxin/sbin/nginx -V
展示信息:
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
configure arguments:
configure arguments后为我们安装的模块。可以看到没有安装ssl模块。
如果你含有ngx_http_ssl_module,那么你可以跳过添加模块这个步骤。
- 进入nginx的安装目录
注意:不是/usr/local/nginx/
我的安装目录是:/usr/local/nginx-1.20.2
里面含有configure文件。

在安装目录下依次输入:
./configure --prefix=/usr/local/nginx./configure --with-http_ssl_modulemakemake install
- 备份nginx。然后将编译好的nginx替换原来的nginx。
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bakcp ./objs/nginx /usr/local/nginx/sbin/
重启nginx并测试
重启:
/usr/local/nginx/sbin/nginx -s reload
测试:
游览器输入https://域名

连接是安全的,成功。
边栏推荐
- Appx code signing Guide
- Flink task exit process and failover mechanism
- unrecognized selector sent to instance 0x10b34e810
- About Tolerance Intervals
- 密码学系列之:在线证书状态协议OCSP详解
- 【基于 RT-Thread Studio的CPK-RA6M4 开发板环境搭建】
- Mathematical induction and recursion
- Sorting operation partition, argpartition, sort, argsort in numpy
- Open3d mesh filtering
- CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
猜你喜欢
随机推荐
存储过程与函数(MySQL)
密码学系列之:在线证书状态协议OCSP详解
杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
HDU ACM 4578 Transformation-> Segment tree - interval change
Hazel engine learning (V)
Lab1 configuration script
Appx code signing Guide
Don't you know the relationship between JSP and servlet?
HDU 4337 King Arthur' S Knights it outputs a Hamiltonian circuit
VHDL实现任意大小矩阵加法运算
ubuntu20安裝redisjson記錄
Open3D 网格滤波
变量、流程控制与游标(MySQL)
ubuntu20安装redisjson记录
RestClould ETL 社区版六月精选问答
input_ delay
SQL Tuning Advisor一个错误ORA-00600: internal error code, arguments: [kesqsMakeBindValue:obj]
SQL中删除数据
小程序能运行在自有App中,且实现直播和连麦?









