您的位置:首页 > 理论基础 > 计算机网络

LInux学习笔记 --https

2017-05-16 22:29 281 查看
HTTPS

1.配置

 

[root@localhost ~]# yum install mod_ssl
crypto-utils -y



[root@localhost ~]# genkey www.westos.com   ##调用genkey,同时为生成的文件指定唯一名称



 

记录生成的证书和关联的私钥的位置

 


继续使用对话框,并选择合适的密钥大小。(默认的2048位密钥为推荐值)

 


在生成随机数时比较慢,敲键盘和移动鼠标可以加速

 




拒绝向认证机构(CA)发送证书请求(CSR)。

 


拒绝加密私钥

 


为服务器提供合适的身份。Common Name必须与服务器的主机全名完全匹配。

 


[root@localhost ~]# cd /etc/pki/tls/private/

[root@localhost private]# ls

localhost.key www.westos.com.key



[root@localhost ~]# mkdir /var/www/virtual/login.westos.com/html -p

[root@localhost ~]# vim /var/www/virtual/login.westos.com/html/index.html

[root@localhost ~]# cat /var/www/virtual/login.westos.com/html/index.html

 


 

[root@localhost ~]# vim /etc/httpd/conf.d/login.conf

<Virtualhost>

ServerName "login.westos.com"

DocumentRoot "/var/www/virtual/login.westos.com/html"

CustomLog "logs/login.log" combined

SSLEngine on
##开启https功能

SSLCertificateFile /etc/pki/tls/certs/www.westos.com.crt
##证书

SSLCertifica
99b5
teKeyFile /etc/pki/tls/private/www.westos.com.key
##密钥

</Virtualhost>

<Directory>

Require all granted
##网页重写实现自动访问https

</Directory>

 

<Virtualhost>

ServerName "login.westos.com"

RewriteEngine on

RewriteRule ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

</Virtualhost>

 

## ^(/.*)$ https://%{HTTP_HOST}$1 [redirect=301]

## ^(/.*)$ 客户主机在地址栏中写入的所有字符

## https:// 定向成为的访问协议

## %{HTTP_HOST} 客户请求主机

## $1 $1的值就表示^(/.*)$的值

## [redirect=301] 临时重定向 302为永久重定向

 


[root@localhost ~]# systemctl restart httpd

 


【浏览器所在主机】

[root@foundation66 ~]# vim /etc/hosts

172.25.254.129 login.westos.com



2.测试

浏览器访问 https://login.westos.com 会自动跳转到 http://login.westos.com 实现网页数据加密传输 







内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: