当前位置:网站首页>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://域名

连接是安全的,成功。
边栏推荐
- 迷失在MySQL的锁世界
- 变量、流程控制与游标(MySQL)
- SQL中删除数据
- HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
- 从0开始创建小程序
- Make (convert) ICO Icon
- Appx code signing Guide
- Starting from 1.5, build a micro Service Framework -- log tracking traceid
- Jericho is in non Bluetooth mode. Do not jump back to Bluetooth mode when connecting the mobile phone [chapter]
- [tools] basic concept of database and MySQL installation
猜你喜欢

杰理之在非蓝牙模式下,手机连接蓝牙不要跳回蓝牙模式处理方法【篇】

leetcode

如何替换模型的骨干网络(backbone)

About Tolerance Intervals

2022.6.28

存储过程与函数(MySQL)

Can the applet run in its own app and realize live broadcast and connection?

Stored procedures and functions (MySQL)

Centerx: open centernet in the way of socialism with Chinese characteristics

OC, OD, push-pull explanation of hardware
随机推荐
input_ delay
美国空军研究实验室《探索深度学习系统的脆弱性和稳健性》2022年最新85页技术报告
Don't you know the relationship between JSP and servlet?
Do you know the five most prominent advantages of E-bidding?
21.(arcgis api for js篇)arcgis api for js矩形采集(SketchViewModel)
“去虚向实”大潮下,百度智能云向实而生
树莓派设置wifi自动连接
Jerry's FM mode mono or stereo selection setting [chapter]
Shell programming basics
Depth analysis of compilation constants, classloader classes, and system class loaders
CMB's written test - quantitative relationship
函数重入、函数重载、函数重写自己理解
cocos3——8. Implementation Guide for beginners
Variables, process control and cursors (MySQL)
What about SSL certificate errors? Solutions to common SSL certificate errors in browsers
应用程序启动速度的优化
22.(arcgis api for js篇)arcgis api for js圆采集(SketchViewModel)
图形化工具打包YOLOv5,生成可执行文件EXE
密码学系列之:在线证书状态协议OCSP详解
「小样本深度学习图像识别」最新2022综述