1. PCRE 설치
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.30.tar.gz
./configure --prefix=/usr/local/pcre make make install
2. APR library 설치
http://apr.apache.org/download.cgi
./configure make make install
3. APU
yum install apr-util-devel
4. unique_ud 설정
아파치 소스파일내 있다.
cd /usr/local/httpd-2.2.21/modules/metadata /usr/local/apache2/bin/apxs -cia mod_unique_id.c
5. Modsecurity 설치
./configure --with-apxs=/usr/local/apache2/bin/apxs
httpd.conf 에 모듈추가
LoadModule unique_id_module modules/mod_unique_id.so LoadModule security2_module modules/mod_security2.so LoadFile /usr/lib/libxml2.so
6. KRCERT의 차단룰 다운로드
http://toolbox.krcert.or.kr/
modsecurity.conf 로 작성하여
/apache2/conf 안에 넣는다.
httpds.conf에
Include conf/modsecury.conf 로 한줄 추가한다.
참고:
특정 웹사이트에서 ModSecurity를 적용하지 않도록 하는 방법!
아래의 함수를 적용할 가상호스트(vhost.conf)에 추가하면 됩니다.
SecRulelnheritance Off
SecRuleEngine Off
<Virtual Host *:80> ServerAlias administrator.website.com ServerAdmin webmaster@website.com DocumentRoot /var/www/html/website.com/ SecRuleInheritance Off ErrorLog logs/website_admin.net-error_log CustomLog logs/website_admin.net-access_log common Options -Indexes ... </VirtualHost>
<VirtualHost 221.111.222.333:80> DocumentRoot /home/domain/domain.org ServerName domain.org ServerAlias *.domain.org ErrorDocument 404 http://domain.org/404.html RewriteEngine on RewriteCond %{HTTP_HOST} ^(domain\.org)(:80)? [NC] RewriteRule ^(.*) http://www.domain.org$1 [R=301,L] SecRuleInheritance Off SecRuleEngine Off <Directory /home/domain/domain.org> AllowOverride all </Directory> </VirtualHost>
특정사이트 제외 시킬때 위의 2가지 조건을 주었지만
아파치가 리스타트시 에러 나는 경우가 있다.
왜 그런지.. 정확히 모름. 지금은 잘된다.
mosecurity2에서는 htaccess를 쓸수 없다.
주의:
modsecurity 설치로 인한 redirect.php?url=http://www.domain.com방식의 링크 에러남.
따라서 ?url에 http:// 들어가면 안된다.
참고사이트:
http://cafe.naver.com/aonenetworks/187
http://goo.gl/1ppL3
http://jnstory.net/1241
http://windowx.tistory.com/363 (APR)
http://goo.gl/D8Uua