Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Apache forbids specifying user_agent (prevents crawlers from scratching)

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

This function can prohibit some of the access lists we don't need (), which can be achieved by rewriting the rewrite module.

Tail / tmp/

Tail / usr/local/apache2/logs/test.com-access_20150121_log

Add the following information to the rewrite module:

RewriteCond% {HTTP_USER_AGENT} ^. * curl.* [NC,OR]

RewriteCond% {HTTP_USER_AGENT} ^. * chrome* [NC]

RewriteRule. *-[F]

Save exit

test

Apachectl-t

Apachectl restart

Curl-x127.0.0.1 80 www.test.com/data/forum.php (default 403 error)

Curl-x192.168.11.160curl 80 www.test.com/data/forum.php (default 403 error)

Vi / usr/local/apache2/conf/extra/httpd-vhosts.conf (commented out)

# RewriteCond% {HTTP_USER_AGENT} ^. * curl.* [NC,OR]

Apachectl-t

Apachectl restart

Curl-x 192.168.11.160 curl 80 www.test.com/adsjkf

Curl-x 192.168.11.160 www.test.com/forum.php 80 www.test.com/forum.php-I)

Browser www.test.com

Curl-A "sdfsadsdfa"-x192.168.11.160 www.test.com/forum.php 80 www.test.com/forum.php-I

Curl-A "sdfsadchrome sdfa"-x192.168.11.160 www.test.com/forum.php 80 www.test.com/forum.php-I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report