Settings for access control:
Assumption: In the log found an IP attempt to attack my site, you can configure the IP to be sealed off.
Copy Template
Vim/usr/local/apache2/conf/httpd.conf
<directory "/usr/local/apache2/cgi-bin" >
AllowOverride None
Options None
Order Allow,deny #Order: Who is in front, who executes first. Do not divide up and down, only points before and after.
Allow from all #允许所有IP
Deny from 127.0.0.1 # control this IP
</Directory>
[Email protected] ~]# apachectl-t
Syntax OK
[Email protected] ~]# apachectl restart
[Email protected] ~]# curl-x127.0.0.1:80-i www.test.com
http/1.1 403 Forbidden #此时访问不到127.0.0.1
Date:tue, Sep 12:31:27 GMT
server:apache/2.2.31 (Unix) php/5.6.24
content-type:text/html; Charset=iso-8859-1
-------------------------------------------------------------------------------------------
Whitelist limit, which restricts the specified IP access.
[Email protected] ~]# vim/usr/local/apache2/conf/extra/httpd-vhosts.conf
<filesmatch "(. *) admin (. *)" >
Order Deny,allow
Deny from all
Allow from 127.0.0.1
</filesmatch>
[Email protected] ~]# apachectl-t
Syntax OK
[Email protected] ~]# apachectl restart
[Email protected] ~]# curl-x10.72.4.30:80-i www.test.com/admin.php
http/1.1 403 Forbidden #限制成功, 403 cannot be accessed
Date:tue, Sep 12:46:15 GMT
server:apache/2.2.31 (Unix) php/5.6.24
content-type:text/html; Charset=iso-8859-1
---------------------------------------------
[Email protected] ~]# curl-x127.0.0.1:80-i www.test.com/admin.php
http/1.1 OK # can be accessed
Date:tue, Sep 12:48:48 GMT
server:apache/2.2.31 (Unix) php/5.6.24
x-powered-by:php/5.6.24
set-cookie:gfwc_2132_saltkey=iyzyty7u; Expires=thu, 27-oct-2016 12:48:48 GMT; max-age=2592000; path=/; HttpOnly
set-cookie:gfwc_2132_lastvisit=1474976928; Expires=thu, 27-oct-2016 12:48:48 GMT; max-age=2592000; path=/
SET-COOKIE:GFWC_2132_SID=POGGLH; expires=wed, 28-sep-2016 12:48:48 GMT; max-age=86400; path=/
set-cookie:gfwc_2132_lastact=1474980528%09admin.php%09; expires=wed, 28-sep-2016 12:48:48 GMT; max-age=86400; path=/
Cache-control:max-age=0
Expires:tue, Sep 12:48:48 GMT
content-type:text/html; Charset=gbk
This article is from the "Cbo#boy_linux Road" blog, make sure to keep this source http://20151213start.blog.51cto.com/9472657/1857339
Apache Configuration access Control