Study Record

[리눅스 서버보안] WAF - ModSecurity install 본문

서버보안/리눅스 서버보안

[리눅스 서버보안] WAF - ModSecurity install

초코초코초코 2022. 1. 6. 09:34
728x90

※ ModSecurityIvan Ristic에 의해 개발한 툴로서 아파치 웹서버에서 동작하는 오픈소스 웹방화벽이다.

 

1. ModSecurity 설치 - Centos 7

㉮ EPEL repository 설정

# yum -y install epel-release

# yum clean all

# yum repolist

 

㉯ mod_security 설치

# yum -y install mod_security mod_security_crs

# rpm -qa | grep mod_security

 

㉰ 패키지 목록 확인

# rpm -ql mod_security

 

2. ModSecurity 기본 설정

구분 ModSecurity 1.X ModSecurity 2.X
Apache 버전 Apache 1.x, 2.x 지원 Apache 2.x Only
처리단계 Inbound(Request body)
Outbound(Response body)
phase:1 (Request header)
phase:2 (Request body)
phase:3 (Response header)
phase:4 (Response body)
phase:5 (Logging)
설정방법 (Apache 1.X) <IfModule mod_security.c>
(Apache 2.X) <IfModule security_module>
<IfModule security2_module>
룰 활성화 SecFilterEngine SecRuleEngine
기본동작 SecFilterDefaultAction SecDefaultAction
지시자 SecFilter, SecFilterSelective SecRule
Request Body 접근 SecFilterScanPost SecRequestBodyAccess(phase:2)
Response Body 접근 SecFilterScanOutput SecResponseBodyAccess(phase:4)

 

2-1. 새롭게 추가된 파일/디렉토리 - modsecurity.d 디렉토리

 

2-2. 설정 파일 - /etc/httpd/mod_security.conf

 

 

2-3. 기본 rule 파일들 - /etc/httpd/modsecurity.d/acivated_rules

 

2-4. 로그 파일 - /var/log/httpd/modsec_*.log

 

2-5. WAF 방화벽 On / Off

# vi /etc/httpd/mod_security.conf

SecRuleEngine Off    # 방화벽 Off

SecRuleEngine On    # 방화벽 On

 

 

 

728x90