WHEREIS

========== nginx =========

server {
        listen       80;
        server_name  1.1.1.1;
        root /123/docu/;
        index index.php;
        charset utf-8;

        set $logging "1";
        set $logtest "";

        if ($http_user_agent ~ "Scrapy") {
                return 403;
        }

.....

 

========== apache =========

<VirtualHost _default_:443>

# General setup for the virtual host, inherited from global configuration
DocumentRoot "/var/www/html/"
#ServerName www.example.com:443

RewriteEngine  on
RewriteCond %{HTTP_USER_AGENT}  ^Scrapy
RewriteRule ^.* - [F,L]

.....



아파치의 경우 rewrite 외에 Direcoty 지시어를 이용해 아래와 같이 처리 가능하다

 

SetEnvIfNoCase User-Agent "^Scrapy" test

 

<Direco....>

      Order allow,deny
      Allow from all
      Deny from env=test

</Dire....>

 

 

검증은 아래와 같이 하면 된다.

curl http://localhost -L --insecure --user-agent "에이전트명"

이 글을 공유합시다

facebook twitter kakaoTalk kakaostory naver band
loading