Get the App
SLTechnology News&Howtos  ›  Network Security  › 

Access control for Apache configuration

Shulou Source: shulou.com Published: 2022-06-01 01:44:03 10月04日 Update

Settings for access control:

Suppose: if you find an IP trying to * * my site in the log, you can block the IP through configuration.

Copy template

Vim / usr/local/apache2/conf/httpd.conf

AllowOverride None

Options None

Order allow,deny # Order: whoever comes first executes first. Neck and neck, only before and after.

Allow from all # allows all IP

Deny from 127.0.0.1 # controls this IP

[root@OBird ~] # apachectl-t

Syntax OK

[root@OBird ~] # apachectl restart

[root@OBird ~] # curl-x127.0.0.1 www.test.com 80-I

HTTP/1.1 403 Forbidden # can't access 127.0.0.1 at this time

Date: Tue, 27 Sep 2016 12:31:27 GMT

Server: Apache/2.2.31 (Unix) PHP/5.6.24

Content-Type: text/html; charset=iso-8859-1

-

Whitelist restrictions that restrict specified IP access.

[root@OBird ~] # vim / usr/local/apache2/conf/extra/httpd-vhosts.conf

Order Deny,Allow

Deny from all

Allow from 127.0.0.1

[root@OBird ~] # apachectl-t

Syntax OK

[root@OBird ~] # apachectl restart

[root@OBird ~] # curl-x10.72.4.30 www.test.com/admin.php 80-I

HTTP/1.1 403 Forbidden # restricted successfully, 403 cannot be accessed

Date: Tue, 27 Sep 2016 12:46:15 GMT

Server: Apache/2.2.31 (Unix) PHP/5.6.24

Content-Type: text/html; charset=iso-8859-1

-

[root@OBird ~] # curl-x127.0.0.1 www.test.com/admin.php 80-I

HTTP/1.1 200OK # can visit

Date: Tue, 27 Sep 2016 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, 27 Sep 2016 12:48:48 GMT

Content-Type: text/html; charset=gbk

Tags: Limit control configure success neck and neck can pass list copy log template site try Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple vpn Xiaomi Docker