티스토리 뷰

Linux

mod_geoip + httpd

초보의 CHOMAN 2019.08.26 18:07

mod_geoip + httpd

참고 원문 사이트

https://www.tecmint.com/install-mod_geoip-for-apache-in-centos/

설치

yum install epel-release
yum install mod_geoip GeoIP GeoIP-devel GeoIP-data zlib-devel

DB 업그레이드?

# cd /usr/share/GeoIP/
# mv GeoIP.dat GeoIP.dat_org
# wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz
# wget http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
# gunzip GeoLite2-Country.tar.gz
# gunzip GeoLite2-City.tar.gz

mod_geoip 설정

vi /etc/httpd/conf.d/geoip.conf

<IfModule mod_geoip.c>
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat MemoryCache
</IfModule>

redirect

# Redirect one country
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^AS$
RewriteRule ^(.*)$ https://www.tecmint.com$1 [R,L]

blocking

SetEnvIf GEOIP_COUNTRY_CODE AS BlockCountry
SetEnvIf GEOIP_COUNTRY_CODE US BlockCountry
# ... place more countries here

Deny from env=BlockCountry

allow

SetEnvIf GEOIP_COUNTRY_CODE AS AllowCountry
SetEnvIf GEOIP_COUNTRY_CODE US AllowCountry
# ... place more countries here

Deny from all
Allow from env=AllowCountry

'Linux' 카테고리의 다른 글

리눅스 whois 명령어  (0) 2019.08.27
smt  (0) 2019.08.27
mod_geoip + httpd  (0) 2019.08.26
firewalld + geoip with CentOS7  (0) 2019.08.26
Can't locate NetAddr/IP.pm in @INC  (0) 2019.08.26
firewalld + ipset with CentOS7  (0) 2019.08.26
댓글
댓글쓰기 폼