在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
相关推荐
Full Stack Developme3 小时前
Linux 多种压缩格式,优缺点和适用场景
linux·运维·服务器
TG:@yunlaoda360 云老大7 小时前
华为云国际站代理商GeminiDB的企业级高可用具体是如何实现的?
服务器·网络·数据库·华为云
yBmZlQzJ7 小时前
财运到内网穿透域名解析技术机制与中立评估
运维·经验分享·docker·容器·1024程序员节
Shanxun Liao7 小时前
Cenots 7.9 配置多台 SSH 互信登陆免密码
linux·运维·ssh
j_xxx404_7 小时前
Linux:第一个程序--进度条|区分回车与换行|行缓冲区|进度条代码两个版本|代码测试与优化
linux·运维·服务器
一点晖光7 小时前
jenkins优化记录
运维·jenkins
最贪吃的虎8 小时前
Git: rebase vs merge
java·运维·git·后端·mysql
yBmZlQzJ9 小时前
内网穿透工具通过端口转发实现内外网通信
运维·经验分享·docker·容器·1024程序员节
DeepHacking9 小时前
Overleaf 本地Docker部署
运维·docker·容器
llilian_169 小时前
总线授时卡 CPCI总线授时卡的工作原理及应用场景介绍 CPCI总线校时卡
运维·单片机·其他·自动化