标签:timeout auth 主机名 www log emc info serve rest
Apache连接保持* KeepAlive
是否打开连接保持,off关闭,on打开
* KeepAliveTimeout
一次连接多次请求之间的最大间隔时间,两次请求超过该时间连接断开
* MaxKeepAliveRequests
一次连接能够传输的最大请求数量
控制对网站资源的访问
为特定的网站目录添加访问授权
客户机地址限制
用户授权限制
1. 使用Require配置项实现访问控制,按先后顺序限制
2. 可用于<Location>,<Directory>,<Files>,<Limit>配置段中
3. Require配置项的常见语法
* Require all granted
* Require all denied
* Require local
* Require [not] host <主机名或域名列表>
* Require [not] ip <IP地址或网段列表>
使用not禁止访问时要将其置于<RequireAll></RequireAll>
容器中并在容器中指定相应的限制策略
上篇博客配置好的accp,naccp网页
一台测试主机(192.168.13.135)
[root@localhost /]# cd /etc/httpd/conf/extra ##切换到扩展配置文件目录
[root@localhost extra]# vim vhost.conf
##accp的配置文件内容
<VirtualHost 192.168.13.133:80>
Documentroot "/var/www/html/accp/"
ServerName www.accp.com
Errorlog "logs/www.accp.com.error_log"
Customlog "logs/www.accp.com.access_log" common
<Directory "/var/www/html/">
<RequireAll> ##容器
Require not ip 192.168.13.135 ##禁止测试主机的访问accp
Require all granted
</RequireAll>
</Directory>
##naccp配置文件的内容
</VirtualHost>
<VirtualHost 192.168.13.132:80>
Documentroot "/var/www/html/accp02/"
ServerName www.naccp.com
Errorlog "logs/www.accp02.com.error_log"
Customlog "logs/www.accp02.com.access_log" common
<Directory "/var/www/html/">
Require all granted
</Directory>
</VirtualHost>
[root@localhost extra]# systemctl restart httpd.service ##重启网络服务
[root@localhost ~]# cd /etc/httpd/conf
[root@localhost conf]# htpasswd -c /etc/httpd/conf/pwd test01
##创建加密文件,如果文件存在则不需要加-c
New password: ##输入密码
Re-type new password: ##再次输入密码
Adding password for user test01
[root@localhost conf]# cat pwd ##查看用户及密文
test01:$apr1$LqlktXok$lUk/5byVWXbvv6dNdRsFg1
[root@localhost ~]# cd /etc/httpd/conf/extra
[root@localhost extra]# vim vhost.conf
<VirtualHost 192.168.13.133:80> ##此段不需要更改
Documentroot "/var/www/html/accp/"
ServerName www.accp.com
Errorlog "logs/www.accp.com.error_log"
Customlog "logs/www.accp.com.access_log" common
<Directory "/var/www/html/">
<RequireAll>
Require not ip 192.168.13.135
Require all granted
</RequireAll>
</Directory>
</VirtualHost>
##修改此段directory内容
<VirtualHost 192.168.13.132:80>
Documentroot "/var/www/html/accp02/"
ServerName www.naccp.com
Errorlog "logs/www.accp02.com.error_log"
Customlog "logs/www.accp02.com.access_log" common
<Directory "/var/www/html/">
AuthName "DocumentRoot" ##一段声明
AuthType Basic ##基本验证类型
AuthUserFile /etc/httpd/conf/pwd ##验证文件
Require valid-user ##授权用户验证
</Directory>
</VirtualHost>
[root@localhost extra]# systemctl restart httpd.service ##重启web服务
标签:timeout auth 主机名 www log emc info serve rest
原文地址:https://blog.51cto.com/14080162/2444708