
CentOS/RHEL 7/6에서 Apache와 함께 mod_security를 설치하는 방법
2022-10-18 last update
5 minutes reading ModSecurity Apache mod_security security apache security apache security moduleMod_Security는 웹 서버에서 모듈로 실행되고 당사 웹 애플리케이션에 대한 다양한 공격으로부터 보호하는 웹 애플리케이션 방화벽입니다. HTTP 트래픽을 모니터링하고 실시간 분석을 수행합니다. Breach Security에서 개발한 제품이며 GNU 라이선스에 따라 무료로 사용할 수 있습니다. Apache, Nginx 및 IIS에서 사용할 수 있습니다.Mod_Security는 현재 웹 서버 인프라와 배포 및 통합할 수 있습니다. 즉, 내부 네트워크를 수정할 필요가 없고 장애 지점을 추가하지 않고 로드의 이점을 누릴 수 있습니다. 밸런싱 및 확장성 및 압축 또는 암호화된 데이터에 문제가 없을 것입니다. Mod_Security는 가치 있는 보안 도구이며 효과적인 것으로 입증되었습니다. 웹 애플리케이션을 보호하려면 이 도구에 주의를 기울여야 합니다.
켜기 - 규칙이 활성화됨
꺼짐 – 규칙이 비활성화됨
DetectionOnly – 트랜잭션만 가로채고 기록합니다. 공격을 가로채고 차단하기를 원하므로 On으로 구성합니다. Mod 보안 구성 파일 –/etc/httpd/conf.d/mod_security.conf 디버그 로그 –/var/log/httpd/modsec_debug.log 감사 로그 –/var/log/httpd/modsec_audit.log 규칙 –/etc/httpd/modsecurity.d/activated_rules 참조:
https://www.modsecurity.org/
https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual
1단계 – EPEL 리포지토리 활성화
먼저 다음 명령을 사용하여 시스템에 EPEL rpm 저장소를 추가합니다.### For RHEL/CentOS 7 rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm ### For RHEL/CentOS 6 rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
2단계 – Mod_Security 및 사전 정의된 규칙 설치
mod_security의 미리 정의된 규칙을 사용하여 mod_security Apache 모듈을 설치해 보겠습니다.yum install mod_security mod_security_crs
3단계 – mod_security 모듈 활성화
ModSecurity 구성 파일/etc/httpd/conf.d/mod_security.conf를 편집하고 파일에서 SecRuleEngine 지시문을 찾고 원하는 값으로 구성합니다.켜기 - 규칙이 활성화됨
꺼짐 – 규칙이 비활성화됨
DetectionOnly – 트랜잭션만 가로채고 기록합니다. 공격을 가로채고 차단하기를 원하므로 On으로 구성합니다.
SecRuleEngineon
4단계 – Apache를 다시 시작하고 확인
모든 구성을 완료한 후 시스템에서 Apache 서비스를 다시 시작합니다.웹 애플리케이션 방화벽이 작동하는지 확인하려면 Apache 오류 로그에 이와 같은 내용이 표시되어야 합니다.service httpd restart
tail /var/log/httpd/error_log [Sat Mar15 16 09:20:58 2014] [notice] ModSecurity for Apache/2.7.3 (http://www.modsecurity.org/) configured. [Sat Mar15 16 09:20:58 2014] [notice] ModSecurity: APR compiled version=”1.3.9″; loaded version=”1.3.9″ [Sat Mar15 16 09:20:58 2014] [notice] ModSecurity: PCRE compiled version=”7.8 “; loaded version=”7.8 2008-09-05″ [Sat Mar15 16 09:20:58 2014] [notice] ModSecurity: LUA compiled version=”Lua 5.1″ [Sat Mar15 16 09:20:58 2014] [notice] ModSecurity: LIBXML compiled version=”2.7.6″
기억해야 할 중요한 파일
https://www.modsecurity.org/
https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual