在Apache HTTP服务器上配置 TLS加密

  1. 安装mod_ssl软件包
bash 复制代码
[root@localhost conf.d]# dnf install mod_ssl -y

此时查看监听端口多了一个443端口

  1. 自己构造证书
bash 复制代码
[root@localhost conf.d]# cd /etc/pki/tls/certs/
[root@localhost certs]# openssl genrsa > jiami.key
[root@localhost certs]# openssl req -utf8 -new -key jiami.key -x509 -days 100 -out jiami.crt
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [XX]:86
State or Province Name (full name) []:shaaxi
Locality Name (eg, city) [Default City]:xi'an
Organization Name (eg, company) [Default Company Ltd]:rhce
Organizational Unit Name (eg, section) []:peihua
Common Name (eg, your name or your server's hostname) []:www.hehe.com
Email Address []:admin@hehe.com
[root@localhost certs]# mv jiami.key ../private/
[root@localhost certs]# cd -
/etc/httpd/conf.d
[root@localhost conf.d]# ll
total 32
-rw-r--r--. 1 root root 2916 Jul 20  2023 autoindex.conf
-rw-r--r--. 1 root root  400 Jul 20  2023 README
-rw-r--r--. 1 root root 8720 Jul 20  2023 ssl.conf
-rw-r--r--. 1 root root 1252 Jul 20  2023 userdir.conf
-rw-r--r--. 1 root root 1171 Jul  5 15:41 vhost.conf
-rw-r--r--. 1 root root  653 Jul 20  2023 welcome.conf

修改配置文件

bash 复制代码
[root@localhost conf.d]# vim ssl.conf 

重启服务

bash 复制代码
[root@localhost conf.d]# systemctl restart httpd

测试

  1. 在vhost.conf配置文件中添加信息
  1. 测试
    之前在/www/hehe/index.html里写的东西现在还都能访问,证书也构造成功。


在本地访问需要在本地解析文件中添加www.hehe.com主机名

bash 复制代码
[root@localhost conf.d]# vim /etc/hosts
bash 复制代码
[root@localhost conf.d]# curl -k https://www.hehe.com
welcome to hehe
相关推荐
yongui47834几秒前
CentOS系统如何查看当前内存容量
linux·运维·centos
xzq_java6 分钟前
CentOS操作系统虚拟机安装以及连接工具下载和远程连接工具远程连接
linux·运维·centos
Sweety丶╮7941 小时前
【Ansible】实施 Ansible Playbook知识点
服务器·云原生·ansible
ZLRRLZ1 小时前
【Docker】Docker安装
运维·docker·容器
逐梦吧!旅行者1 小时前
Linux之环境变量(内容由浅入深,层层递进)
linux·运维
挨踢攻城2 小时前
Linux 应急响应实操 Checklist
linux·运维·linux命令·rhce·rhca·厦门微思网络·linux 应急响应
wanhengidc2 小时前
什么是云手机?
运维·网络·安全·游戏·智能手机
optiz2 小时前
细菌基因组genome二代测序数据分析
linux·运维·服务器
m0_661316232 小时前
modbus_tcp和modbus_rtu对比&移植AT-socket,modbus_tcp&杂记
服务器·网络·tcp/ip
IT成长日记2 小时前
【Linux基础】Linux系统管理:GPT分区实践详细操作指南
linux·运维·服务器·gpt·parted·磁盘分区·fdisk