티스토리 뷰

해당 작업은 root 계정으로 진행되었고 폴더도 root 폴더에서 진행 됨

 

필요한 패키지 설치

 

yum groupinstall -y "Development Tools"

 

yum install -y http httpd-devel pure pure-devel libxml2 libxml2-devel curl curl-devel openssl openssl-devel pcre-devel wget

 

modSecurity 저장소에서 파일 가져옴

 

git clone --depth 1 -b v3/master --single-branch https://github.com/SpiderLabs/ModSecurity

 

SpiderLabs/ModSecurity

ModSecurity is an open source, cross platform web application firewall (WAF) engine for Apache, IIS and Nginx that is developed by Trustwave's SpiderLabs. It has a robust event-based programmin...

github.com

cd ModSecurity

 

git submodule init && git submodule update && ./build.sh && ./configure && make && make install

 

git clone --depth 1 https://github.com/SpiderLabs/ModSecurity-nginx.git

 

SpiderLabs/ModSecurity-nginx

ModSecurity v3 Nginx Connector. Contribute to SpiderLabs/ModSecurity-nginx development by creating an account on GitHub.

github.com

 

nginx -v

 

버전에 맞는 파일 다운로드

 

wget http://nginx.org/download/nginx-1.18.0.tar.gz

압축 풀고

tar xvzf nginx-1.18.0.tar.gz

 

cd nginx-1.18.0

 

./configure --with-compat --add-dynamic-module=../ModSecurity-nginx

 

make modules

 

cp objs/ngx_http_modsecurity_module.so /etc/nginx/modules

 

모듈 로드/etc/nginx/nginx.conf

vim /etc/nginx/nginx.conf

 

//아랫줄 코드 추가

load_module "modules/ngx_http_modsecurity_module.so";

 

 

// OWASP Core Rule Set 사용

$ cd /etc/nginx/modsec

$ wget https://github.com/SpiderLabs/owasp-modsecurity-crs/archive/v3.1.0.tar.gz

$ tar -xvzf tar -xvzf v3.1.0.tar.gz

$ rm v3.1.0.tar.gz

$ cd v3.1.0.tar.gz/rules

$ cp REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf.example REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conf

$ cp RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf.example RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conf

$ cp /etc/nginx/ModSecurity/modsecurity.conf-recommended /etc/nginx/modsec/modsecurity.conf

$ cp /etc/nginx/ModSecurity/unicode.mapping /etc/nginx/modsec/unicode.mapping

 

// make modsec conf and rules file

$ touch modsec_includes.conf

 

// write below in modsec_includes.conf

include modsecurity.conf

include owasp-modsecurity-crs/crs-setup.conf

include owasp-modsecurity-crs/rules/*.conf

 

// “detection only” 모드에서 actively dropping traffic 로 변경

$ sed -i 's/SecRuleEngine DetectionOnly/SecRuleEngine On/' /etc/nginx/modsec/modsecurity.conf

 

 

#nginx 호스팅 설정에 추가

cd /etc/nginx/conf.d

 

vim default.conf

 

modsecurity on;

modsecurity_rules_file /etc/nginx/modsec/modsec_includes.conf;

 

 

참조 블로그

Nginx open source 에 ModSecurity v3 웹방화벽 모듈 설치 - VoidNoble IT Zone (tistory.com)

 

Nginx open source 에 ModSecurity v3 웹방화벽 모듈 설치

사전 요구 사항 1. Nginx latest 를 official repository 로부터 설치 nginx.org/en/linux_packages.html#mainline 2. 사전요구 패키지 설치 * Ubuntu $ apt-get install -y apt-utils autoconf automaker build-e..

itzone.tistory.com

 

Nginx에 ModSecurity 웹방화벽 설치 :: onsemiro (tistory.com)

 

Nginx에 ModSecurity 웹방화벽 설치

* Ubuntu 18.04.4 LTS / Nginx 1.19.0 버전에서 테스트 했습니다. * Ubuntu에 Nginx가 설치되어있다고 가정합니다. libmodsecurity 다운 및 컴파일 // Clone $ git clone --depth 1 -b v3/master --single-branch..

sronsemiro.tistory.com

 

 

'serverSide > Linux' 카테고리의 다른 글

cloudflare + nginx + xml 속도지연  (0) 2021.06.23
[nginx] aceess.log awk 이용  (0) 2021.03.11
[CentOS7]특정 계정 su 명령어 막기  (0) 2021.03.04
[CentOS7] php7.2 + mssql(sqlsrv)  (0) 2021.03.04
[crontab]php url 실행  (0) 2021.02.26
댓글