일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 |
- apple push notification service (apns) is changing
- sha-2 root
- html pdf 변환
- PHP 정규식 예제
- usb efi 시스템 파티션 삭제
- bootstrap modal
- modsecurity 설치
- 유튜브 플레이 리스트 저장
- 비밀번호검증정규식
- bootstrap
- mysqldump: Got error: 1045
- php 배열제거
- (using password: YES)" when trying to connect
- 아파치 웹 서버의 정보 숨기기
- javascript
- mod_security2 설치
- thumbnail 클래스
- 비밀번호정규식
- 윈도우 환경 아파치 mod_security2 설치
- httpd.conf 보안 설정
- 파라미터 & 오류
- mariadb upgrade
- wsl2 우분투에 docker 설치
- PHP 구글 OTP 연동
- 자바스크립트비밀번호검증
- 숫자 3자리(천단위) 마다 콤마 찍기
- postfix 설치
- 윈도우 mod_security2
- php 이미지 url 검증 함수
- group_concat 구분자
- Today
- Total
투덜이 개발자
윈도우 환경 아파치 mod_security2 설치 본문
적용환경
운영체체 : 윈도우 11
아파치 버전 : Server version: Apache/2.4.62 (Win64) Apache Lounge VS17 Server built
1. mod_security 설치
mod_security-2.9.8-win64-VS17.zip 파일 다운도르
다운로드 : https://www.apachelounge.com/download/VS17/modules/mod_security-2.9.8-win64-VS17.zip
압축을 풀어서
- yajl.dll 설치
apache24/bin 디렉토리에 yajl.dll 복사
- mod_security2.so 설치
apache24/modules 디렉토리에 mod_security2.so 복사
2. owasp-modsecurity-crs 설치
owasp-modsecurity-crs-3.2.0.zip 다운로드
다운로드 : https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/refs/tags/v3.2.0.zip
- owasp-modsecurity-crs 설정
apache24/conf 디렉토리에 crs 디렉토리를 만들고
압축파일 내에 있는 crs-setup.conf.example파일과 rules 디렉토리를 복사합니다.
그리고 crs-setup.conf.example 파일 이름을 crs-setup.conf 로 변경합니다.
3. modsecurity.conf 설정
modsecurity.conf-recommended 파일을 modsecurity.conf 로 복사후
C:\Apache\httpd-2.4.62-240904-win64-VS17\Apache24\conf\extra 에 옮긴다.
modsecurity.conf 파일을 열어 최상단에 다음과 같이 수정합니다. #SecRuleEngine DetectionOnly
SecRuleEngine On
SecDefaultAction "deny,phase:2,status:403"
ServerTokens Prod
ServerSignature Off
SecServerSignature "TestServer"
맨 하단에 다음과 같이 추가합니다.
Include conf/crs/crs-setup.conf
Include conf/crs/rules/*.conf
4. httpd.conf 설정
LoadModule unique_id_module modules/mod_unique_id.so
LoadModule security2_module modules/mod_security2.so
<IfModule security2_module>
Include conf/extra/modsecurity.conf
SecRuleEngine On
</IfModule>
* 에러처리
즉, Apache가 mod_security2.so 파일을 찾긴 했지만 해당 모듈을 로드하는 데 필요한 의존 라이브러리(DLL 등)가 누락된 경우입니다. 윈도우 환경에서 흔히 발생하는 문제예요.
Visual C++ Redistributable for Visual Studio 2015, 2017, 2019, 2022 (x64) 설치
다운로드 : https://aka.ms/vs/17/release/vc_redist.x64.exe
c:\var\log 디렉토리를 만들어 준다.
즉, modsecurity.conf에서 참조하고 있는 unicode.mapping 파일이 없어서 Apache가 시작되지 않는 것입니다.
다운로드 : https://raw.githubusercontent.com/SpiderLabs/ModSecurity/v2/master/unicode.mapping
다운로드 한 파일을 C:/Apache/httpd-2.4.62-240904-win64-VS17/Apache24/conf/extra/ 에 옮긴다.
5. 동작확인
error.log에서 아래와 같은 로그를 확인하거나, 테스트 공격 문자열을 요청하여 차단되는지 확인:
예: curl "http://localhost/?param=<script>alert(1)</script>"