最近ログを見ると、海外の変なサイトからのRefererが多かったため拒否する設定をしてみました。
■OS
CentOS 6 64bit
■Apacheバージョン
httpd-2.2.15-5.el6.centos.x86_64
■拒否するRefererアドレス(例)
http://www.example.com
http://www.test.com
(1)拒否するRefererのリストファイルを作成
[root@example ~]# vi /etc/httpd/conf.d/referer_deny_list.conf SetEnvIf Referer "http://www.example.com" referer_deny SetEnvIf Referer "http://www.test.com" referer_deny
(2)Apacheの設定を変更
[root@example ~]# vi /etc/httpd/conf/httpd.conf <Directory "/var/www/html"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews (snip) # # Controls who can get stuff from this server. # Order allow,deny Allow from all Deny from env=referer_deny </Directory>※ここでは、「/var/www/html」直下を対象とします。
(3)設定の再読み込み
[root@example ~]# service httpd reload httpd を再読み込み中:
これで、拒否するRefererアドレスからリンクで飛んできても拒否(Forbidden)されます。
[...] 回はリファラーに注目してapacheでアクセス制限をかけてみることにしました。 参考になりそうな情報はネット上に多々あるのですが、今回は特にコチラを参考にさせていただきました。 [...]