facebookのIPがmod_geoipで拒否される対応
...こんにちは。プラットフォームの小宮です。
apacheのmod_geoipモジュールで海外を拒否してみたところ、
Facebookの画像が表示されないということで対応しました。・whoisが必要だが入ってなかったので他の入ってるサーバでパッケージ名を調べて導入
[shell]$ which whois /usr/bin/whois # rpm -qf /usr/bin/whois jwhois-3.2.2-1
# yum install jwhois Installed: jwhois.x86_64 0:4.0-19.el6 # which whois /usr/bin/whois[/shell]
・fb公式で許可リスト取得方法を確認
以下のコマンドで定期的に更新リストを取得せよと公式に書いてある。
App Security - Facebook開発者[shell]# whois -h whois.radb.net – ‘-i origin AS32934’ | grep ^route:|awk ‘{print $2}’ 204.15.20.0/22 69.63.176.0/20 ~略~ 69.63.184.0/21 66.220.144.0/20 69.63.176.0/20[/shell] ※65ブロックくらいだった。手作業はあり得ないので何とか自動化を試みる。
・設定追加方法の検討
この辺に追記できるか考えてみる。
[shell]# cat /etc/cron.monthly/geoip #!/bin/bash wget -q http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz gunzip GeoIP.dat.gz mv -f GeoIP.dat /usr/share/GeoIP/GeoIP.dat[/shell]
datはバイナリなので自分で追記は困難。軽くググってもそんなことしてる人いない。
[shell]# file /usr/share/GeoIP/GeoIP.dat /usr/share/GeoIP/GeoIP.dat: data[/shell]