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;
}
相关推荐
物联网老王5 小时前
Ubuntu Linux Cursor 安装与使用一
linux·运维·ubuntu
一位摩羯座DBA7 小时前
Redhat&Centos挂载镜像
linux·运维·centos
学习3人组7 小时前
CentOS配置网络
linux·网络·centos
charlee447 小时前
nginx部署发布Vite项目
nginx·性能优化·https·部署·vite
weixin_307779137 小时前
Hive集群之间迁移的Linux Shell脚本
大数据·linux·hive·bash·迁移学习
漫步企鹅8 小时前
【蓝牙】Linux Qt4查看已经配对的蓝牙信息
linux·qt·蓝牙·配对
cui_win8 小时前
【网络】Linux 内核优化实战 - net.core.flow_limit_table_len
linux·运维·网络
梦在深巷、8 小时前
MySQL/MariaDB数据库主从复制之基于二进制日志的方式
linux·数据库·mysql·mariadb
冰橙子id9 小时前
linux系统安全
linux·安全·系统安全
stark张宇9 小时前
VMware 虚拟机装 Linux Centos 7.9 保姆级教程(附资源包)
linux·后端