linux 生成 nginx 的https ssl 证书详解

证书生成

1. 生成证书

会提示输入密码,输入两次相同密码即可。

clike 复制代码
openssl genrsa -des3 -out server.key 2048

2. 去除密码校验

如果想去除此输密码的步骤,可以执行如下命令,根据使用需求选择。

c 复制代码
openssl rsa -in server.key -out server.key

3.创建证书申请文件

根据要求填写证书申请相关信息。

c 复制代码
openssl req -new -key server.key -out server.csr

4.生成自签证书,即根证书CA

c 复制代码
openssl req -new -x509 -key server.key -out ca.crt -days 3650

5.创建服务器证书

c 复制代码
openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey server.key -CAcreateserial -out server.crt

至此,证书生成完成。

Nginx配置https

  1. 把刚才生成的文件 server.key,server.crt 拷贝至nginx所在服务器的目录下。
  2. 编辑nginx文件 nginx.conf,指定文件所在的路径。
c 复制代码
server {
    listen         15021 ssl;
    server_name    127.0.0.1;

    ssl_certificate      /etc/nginx/ssl/server.crt;
    ssl_certificate_key  /etc/nginx/ssl/server.key;
    ssl_session_timeout  5000m;
    ssl_protocols        TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers          HIGH:!aNULL:!MD5;
    ssl_prefer_server_ciphers  on;
}
相关推荐
影视飓风TIM2 分钟前
Linux下C语言缓冲区原理 + Git版本控制
linux·c语言·git
来者皆善23 分钟前
ZYNQ linux上使用 USB CDC ACM
linux·运维·服务器
Dawn-bit2 小时前
Linux磁盘分区与Swap和磁盘故障查询
linux·运维·服务器·网络·云计算
无足鸟ICT3 小时前
【RHCA+】$[]
linux·运维·服务器
运维技术小记4 小时前
国产化环境配置 VNC 远程桌面:麒麟 V10 实战
linux·运维·服务器
xiaoye-duck4 小时前
《Linux系统编程》Linux 系统多线程(八): C++ 高并发线程池全链路深度解析与从零手撕实现
linux·c++·线程池
寒水馨5 小时前
Linux下载、安装protobuf-v35.1(附安装包protoc-35.1-linux-x86_64.zip)
linux·运维·服务器·google·序列化·protobuf·protoc
王琦03185 小时前
Linux的文件管理
linux·运维·服务器
☆凡尘清心☆5 小时前
CentOS Stream 9 Redis 7.2.7 源码编译一键安装脚本
linux·运维·redis·centos
Android系统攻城狮5 小时前
Linux PipeWire深度解析之pw_stream_new调用流程与实战(四十二)
linux·运维·服务器·音频进阶·pipewire音频进阶