http,https

在这里插入图片描述

yum install httpd -y
yum install mod_ssl -y

<>为起始标志,</>为结束标志
AllowOverride none 不允许这个目录下的访问控制文件来改变这里的配置,这也意味着不用查看这个目录下的访问控制文件。

vim /etc/httpd/conf.d/openlab.conf

<VirtualHost 172.24.8.130:80>

DocumentRoot /www *主目录
ServerName www.openlab.com

<VirtualHost 172.24.8.130:443>
DocumentRoot /hh *主目录为/ hh(还需要至少一个次目录)
ServerName www.openlab.com
SSLEngine on
SSLcertificatefile /etc/pki/tls/certs/money.crt
SSlcertificatekeyfile /etc/pki/tls/certs/money.key

<Directory /hh> *访问控制
ALLowOverride none *不允许覆盖
Require all granted *授权所有用户可以访问 /hh

<Directory /www>
ALLowOverride none
Require all granted

<Directory /www/student>
AuthType Basic *认证类型
AuthName “miaoshu” *认证描述
AuthUserFile /etc/httpd/users *自定义的认证文件路径
Require user song tian *认证用户

:wq

mkdir -p /hh/money
mkdri -p /www/student
mkdir /www/data
echo this is money > /hh/money/index.html
echo this is student > /www/student/index.html
echo this is data > /www/data/index.html
echo welcome to openlab > /www/index.html

cd /etc/pki/tls/certs 创私钥
/usr/bin/openssl genrsa -aes128 2048 > money.key
输入密码
openssl req -utf8 -new -key money.key -x509 -days 365 -out money.crt -set_serial 0
给私钥颁证书

htpasswd -c /etc/httpd/users tian
htpasswd /etc/httpd/users song

vim /etc/hosts
172.24.8.130 www.openlab.com

systemctl stop firewalld
setenforce 0
systemctl restart httpd

curl http://www.openlab.com/
curl http://www.openlab.com/data/
curl http://www.openlab.com/student/ -u tian
curl -k https://www.openlab.com/money/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值