在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
相关推荐
wanhengidc16 分钟前
如何使用云手机进行游戏挂机?
运维·服务器·游戏·智能手机·云计算
汪汪大队u23 分钟前
为什么 filter-policy 仅对 ASBR 的出方向生效,且即使在该生效场景下,被过滤的路由在协议内部(如协议数据库)依然存在,没有被彻底移除?
服务器·前端·网络
kyle~25 分钟前
设计模式---观察者模式
服务器·观察者模式·设计模式
wangjialelele41 分钟前
端口号、常见协议和套接字
linux·运维·服务器·c语言·网络
木易 士心41 分钟前
Nginx 基本使用和高级用法详解
运维·javascript·nginx
蜜蜜不吃糖1 小时前
ESXI主机重置带外密码
linux·运维·服务器
王道长服务器 | 亚马逊云1 小时前
AWS CloudTrail:让每一次操作都“有迹可循”
服务器·网络·云计算·智能路由器·aws
智象科技1 小时前
CMDB报表体系如何驱动智能运维
大数据·运维·报表·一体化运维·cmdb
高光视点1 小时前
伊萨推出升级版SUPRAREX™ PRO自动化切割设备:更大尺寸、更强结构、更高安全性、更易维护
运维·自动化
b***25112 小时前
深圳比斯特自动化|圆柱电池测试设备核心功能与技术发展解析
运维·自动化