https简介
搭建https安全传输网站
[root@apache-server ~]# yum install mod_ssl.x86_64 crypto-utils.x86_64 -y
[root@apache-server ~]# genkey www.westos.com
执行上述命令会进入到图形界面制作密钥
[root@apache-server ~]# vim /etc/httpd/conf.d/ssl.conf
100 SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
107 SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
[root@apache-server ~]# systemctl restart httpd.service
测试
设定https虚拟主机并网页重写实现自动跳转https
[root@apache-server ~]# mkdir -p /var/www/westos.com/login/html
[root@apache-server ~]# vim /var/www/westos.com/login/html/index.html
[root@apache-server ~]# cp /etc/httpd/conf.d/news.conf /etc/httpd/conf.d/login.conf
[root@apache-server ~]# vim /etc/httpd/conf.d/login.conf
1 <VirtualHost *:443>
2 SSLEngine on
3 ServerName login.westos.com
4 DocumentRoot /var/www/westos.com/login/html
5 CustomLog logs/login.log combined
6 SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
7 SSLCertificateKeyFile /etc/pki/tls/private/www.westos.com.key
8 </VirtualHost>
9 <Directory "/var/www/westos.com/login/html">
10 Require all granted
11 </Directory>
12 <VirtualHost *:80>
13 ServerName login.westos.com
14 RewriteEngine on
15 RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]
16 </VirtualHost>
[root@apache-server ~]# systemctl restart httpd.service
在本地做域名解析、测试
删除证书