在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 []:[email protected]
[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
相关推荐
瀚高PG实验室34 分钟前
连接指定数据库时提示not currently accepting connections
运维·数据库
QQ27402875634 分钟前
Soundness Gitpod 部署教程
linux·运维·服务器·前端·chrome·web3
淡忘_cx1 小时前
【frp XTCP 穿透配置教程
运维
南方以南_1 小时前
Ubuntu操作合集
linux·运维·ubuntu
爱吃芝麻汤圆1 小时前
k8s之Kubebuilder 的设计哲学
云原生·容器·kubernetes
purrrew1 小时前
【Java ee初阶】HTTP(2)
网络·网络协议·http
火星数据-Tina1 小时前
从HTTP轮询到WebSocket:如何让体育API性能提升100倍?
websocket·网络协议·http
冼紫菜2 小时前
[特殊字符]CentOS 7.6 安装 JDK 11(适配国内服务器环境)
java·linux·服务器·后端·centos
裁二尺秋风3 小时前
k8s(12) — 版本控制和滚动更新(金丝雀部署理念)
云原生·容器·kubernetes
项目題供诗3 小时前
黑马k8s(六)
云原生·容器·kubernetes