用户认证方式HTTP+HTTPS

1 mkdir /usr/local/maomao
2 echo this is maomao > /usr/local/maomao/index.html
3 vim /etc/httpd/conf.d/vhosts.conf
<Directory /usr/local/maoao>
#允许覆盖
AllowOverride none
#设置访问目录权限
Require all granted

<Directory /usr/local/maomao>
AuthType Basic //基本认证类型
AuthName “This is a private directory:Please login:” 认证提示名称
AuthUserFile /etc/httpd/htuser 用户认证长账号密码文件
Require user abc xyz 指定可认证用户

LISTEN 8080
<VirtualHost 192.168.10.140:8080>
DocumentRoot /usr/local/maomao
ServerName 192.168.10.140
ErrorLog “/var/log/httpd/error_log”
CustomLog “/var/log/httpd/access_log” common

4  htpasswd /etc/httpd/htuser abc
5  htpasswd /etc/httpd/htuser xyz
6  setenforce 0

7 systemctl restart httpd
在这里插入图片描述

在这里插入图片描述
2.
mkdir /www/openlab
mkdir /www/openlab/student
mkdir /www/openlab/data //创建目录
mkdir /www/money
vim /www/money/index.html
vim /www/openlab/index.html
vim /www/openlab/student/index.html //为网页写入内容
vim /www/openlab/data/index.html
htpasswd /etc/httpd/htuser song //创建认证用户
htpasswd /etc/httpd/htuser tian
vim /etc/hosts //写ip和域名的映射
cd /etc/pki/tls/certs/
make openlab.crt //创建证书
systemctl restart httpd
vim /etc/httpd/conf.d/vhosts.conf
<VirtualHost 192.168.10.160:80>
DocumentRoot /www/openlab
ServerName www.openlab.com

<Directory /www/openlab/student> //用户认证
AuthType Basic
AuthName "Please Input HostName and Password "
AuthUserFile /etc/httpd/htusr
Require user song tian

<VirtualHost 192.168.10.160:443> //openlab的money的https
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
SSLCertificateFile /etc/pki/tls/certs/openlab.crt
SSLCertificateKeyFile /etc/pki/tls/certs/openlab.key
DocumentRoot /www/openlab
ServerName www.openalb.com
Alias /money /www/money
ErrorLog “/var/log/httpd/error_log”
CustomLog “/var/log/httpd/access_log” common

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述在这里插入图在这里插入图片描述片描述

猜你喜欢

转载自blog.csdn.net/qq_39396529/article/details/84397401
今日推荐