当前位置:网站首页>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_module
make
make install
- 备份nginx。然后将编译好的nginx替换原来的nginx。
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak
cp ./objs/nginx /usr/local/nginx/sbin/
重启nginx并测试
重启:
/usr/local/nginx/sbin/nginx -s reload
测试:
游览器输入https://域名

连接是安全的,成功。
边栏推荐
- LAB1配置脚本
- [safe office and productivity application] Shanghai daoning provides you with onlyoffice download, trial and tutorial
- Opencv environment, and open a local PC camera.
- cocos3——8. Implementation Guide for beginners
- 杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】
- CMB's written test - quantitative relationship
- Leetcode-02 (linked list question)
- Numpy中排序操作partition,argpartition,sort,argsort
- 华为小米互“抄作业”
- Hazel engine learning (V)
猜你喜欢
Huawei and Xiaomi "copy each other"
OC, OD, push-pull explanation of hardware
The latest 2022 review of "small sample deep learning image recognition"
23.(arcgis api for js篇)arcgis api for js椭圆采集(SketchViewModel)
2022.6.28
CVPR 2022 最佳论文候选 | PIP: 6个惯性传感器实现全身动捕和受力估计
21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
Another million qubits! Israel optical quantum start-up company completed $15million financing
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
Create applet from 0
随机推荐
pip只下载不安装
20.(arcgis api for js篇)arcgis api for js面采集(SketchViewModel)
2022.6.28
Optimization of application startup speed
SQL中删除数据
Experience design details
Flink task exit process and failover mechanism
安装 torch 0.4.1
「小样本深度学习图像识别」最新2022综述
Matlab Error (Matrix dimensions must agree)
MOS transistor realizes the automatic switching circuit of main and auxiliary power supply, with "zero" voltage drop and static current of 20ua
Jerry's broadcast has built-in flash prompt tone to control playback pause [chapter]
枚举通用接口&枚举使用规范
CVPR 2022 best paper candidate | pip: six inertial sensors realize whole body dynamic capture and force estimation
Not All Points Are Equal Learning Highly Efficient Point-based Detectors for 3D LiDAR Point
如何自定义Latex停止运行的快捷键
Domcontentloaded and window onload
About Tolerance Intervals
Centerx: open centernet in the way of socialism with Chinese characteristics
Jericho turns on the display icon of the classic Bluetooth hid mobile phone to set the keyboard [chapter]