NGINX App Protect WAF V5 설치 가이드
해당 블로그 포스트는 호스트 기반 NGINX 설정을 위한 NGINX App Protect WAF V5 설치 단계를 설명합니다.
목차
1. 전제 조건
2. NGINX 및 NGINX App Protect WAF V5 모듈 설치
2-1. Alpine Linux 3.16 / Alpine Linux 3.17
2-2. Amazon Linux 2
2-3. Debian 11 / Debian 12
2-4. RHEL 7.4+ / CentOS 7.4+
2-5. RHEL 8.1+ / Oracle Linux 8.1+
2-6. RHEL 9
2-7. Ubuntu 20.04 / Ubuntu 22.04
3. NGINX App Protect WAF V5 를 위한 NGINX 구성
4. NGINX App Protect WAF V5 서비스 구성
4-1. NGINX App Protect WAF V5 Permission
4-2. NGINX App Protect WAF V5 F5 컨테이너 레지스트리를 위한 Docker 설정
4-3. NGINX App Protect WAF V5 Docker Compose 파일
5. NGINX App Protect WAF V5 Deployment 시작
6. Policy 및 Logging Profile 번들 사용
7. NGINX 및 NGINX App Protect WAF V5 모듈 삭제
7-1. Docker Deployment 중단
7-2. Alpine Linux 3.16 / Alpine Linux 3.17
7-3. Amazon Linux 2
7-4. Debian 11 / Debian 12
7-5. RHEL 7.4+ / CentOS 7.4+
7-6. RHEL 8.1+ / Oracle Linux 8.1+
7-7. RHEL 9
7-8. Ubuntu 20.04 / Ubuntu 22.04
1. 전제 조건
- NGINX STORE를 통해 활성화 된 NGINX App Protect WAF 구독(또는 Trial License)
- Docker 및 Docker Compose 설치 및 실행
- 지원되는 운영 체제(OS)
2. NGINX 및 NGINX App Protect WAF V5 모듈 설치
이미 시스템에 NGINX 패키지가 있는 경우, 구성 파일 및 로그를 백업하십시오.
sudo cp -a /etc/nginx /etc/nginx-plus-backup
sudo cp -a /var/log/nginx /var/log/nginx-plus-backup
NGINX STORE를 통해 구독 라이선스 혹은 Trial License 파일인 nginx-repo.crt 및 nginx-repo.key 파일을 다운로드하십시오.
기존에 설치된 NGINX App Protect 패키지가 있다면 제거하십시오.
작업 중인 운영 체제에 따라 아래 단계를 따르십시오.
참고:
nginx 또는 nginx-plus가 설치되지 않은 경우, 자동으로 종속 항목으로 설치됩니다.
2-1. Alpine Linux 3.16 / Alpine Linux 3.17
NGINX 오픈소스 & NGINX Plus 공통 작업
1. nginx-repo.key 파일을 /etc/apk/cert.key로 업로드하고, nginx-repo.crt 파일을 /etc/apk/cert.pem으로 업로드하십시오. 파일에 다른 인증서와 키가 포함되지 않도록 하십시오.
Alpine Linux는 서로 다른 리포지토리에 대한 클라이언트 인증서 혼합을 지원하지 않습니다.
2. 필수 패키지 설치
sudo apk add openssl ca-certificates
3. NGINX 서명 공개 키를 /etc/apk/keys 디렉토리에 추가하십시오.
sudo wget -O /etc/apk/keys/nginx_signing.rsa.pub https://cs.nginx.com/static/keys/nginx_signing.rsa.pub
NGINX 오픈소스용
1. mainline nginx 패키지를 위한 apk 리포지토리를 설정하십시오.
printf "%s%s%s\n" \
"http://nginx.org/packages/mainline/alpine/v" \
egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release \
"/main" \
| sudo tee -a /etc/apk/repositories
2. NGINX App Protect WAF apk 리포지토리를 추가하십시오.
printf "https://pkgs.nginx.com/app-protect-x-oss/alpine/vegrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release/main\n" | sudo tee -a /etc/apk/repositories
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo apk add app-protect-module-oss
NGINX Plus용
1. /etc/apk/repositories 파일에 NGINX Plus apk 리포지토리를 추가하십시오.
printf "https://pkgs.nginx.com/plus/alpine/vegrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release/main\n" | sudo tee -a /etc/apk/repositories
2. NGINX App Protect WAF 리포지토리를 추가하십시오.
printf "https://pkgs.nginx.com/app-protect-x-plus/alpine/vegrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release/main\n" | sudo tee -a /etc/apk/repositories
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo apk add app-protect-module-plus
2-2. Amazon Linux 2
NGINX 오픈소스 & NGINX Plus 공통 작업
1. /etc/ssl/nginx 디렉토리를 생성하십시오.
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt 및 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드하십시오.
3. 필수 종속 항목을 설치합니다.
sudo yum install ca-certificates wget
4. /etc/yum.repos.d에서 이전에 다운로드한 NGINX 리포지토리 파일을 제거하십시오.
sudo rm /etc/yum.repos.d/nginx*.repo
sudo rm /etc/yum.repos.d/*app-protect*.repo
NGINX 오픈소스용
1. 다음 내용을 포함하는 /etc/yum.repos.d/nginx.repo 파일을 생성하십시오.
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/amzn2/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2. NGINX App Protect WAF 리포지토리 파일을 생성하십시오.
[app-protect-x-oss]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-oss/centos/7/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo yum install app-protect-module-oss
NGINX Plus용
1. NGINX Plus 리포지토리 파일 nginx-plus-amazon2.repo를 /etc/yum.repos.d로 다운로드하십시오.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nginx-plus-amazon2.repo
2. NGINX App Protect WAF 리포지토리 파일을 생성하십시오.
[app-protect-x-plus]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-plus/centos/7/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo yum install app-protect-module-plus
2-3. Debian 11 / Debian 12
NGINX 오픈소스 및 NGINX Plus 공통 단계
1. /etc/ssl/nginx/ 디렉토리를 생성하십시오
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt 및 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드하십시오.
3. 이전 NGINX 리포지토리 및 apt 구성 파일을 제거합니다.
sudo rm /etc/apt/sources.list.d/nginx*.list
sudo rm /etc/apt/sources.list.d/*app-protect*.list
sudo rm /etc/apt/apt.conf.d/90pkgs-nginx
4. 필수 패키지를 설치합니다.
sudo apt-get update && sudo apt-get install apt-transport-https lsb-release ca-certificates wget gnupg2 debian-archive-keyring
5. NGINX Signing Key를 다운로드 및 추가합니다.
wget -qO - https://cs.nginx.com/static/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
6. apt 구성을 /etc/apt/apt.conf.d로 다운로드 합니다.
sudo wget -P /etc/apt/apt.conf.d https://cs.nginx.com/static/files/90pkgs-nginx
7. 다운로드한 파일에 올바른 키가 포함되어 있는지 확인합니다.
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
출력 결과에는 다음과 같이 전체 Fingerprint 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62가 포함되어야 합니다.
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx siging key signing-key@nginx.com
Fingerprint가 다른 경우 파일을 제거하세요.
NGINX 오픈소스용
1. NGINX 오픈소스 리포지토리를 추가합니다.
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \ http://nginx.org/packages/mainline/debian `lsb_release -cs` nginx" \ | sudo tee /etc/apt/sources.list.d/nginx.list
2. 배포 제공 패키지보다 NGINX 패키지를 우선하도록 리포지토리 고정 설정을 합니다.
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
3. NGINX App Protect WAF 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect-x-oss/debian lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect.list
4. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo apt-get update
sudo apt-get install nginx=1.25.4-1~lsb_release -cs app-protect-module-oss
NGINX Plus용
1. NGINX Plus 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/plus/debian lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-plus.list
2. NGINX App Protect WAF 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect-x-plus/debian lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect.list
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo apt-get update
sudo apt-get install app-protect-module-plus
2-4. RHEL 7.4+ / CentOS 7.4+
NGINX 오픈소스 및 NGINX Plus 공통 단계
1. /etc/ssl/nginx 디렉토리를 생성합니다.
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt와 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드합니다.
3. /etc/yum.repos.d에서 이전에 다운로드된 NGINX 리포지토리 파일을 제거합니다.
sudo rm /etc/yum.repos.d/nginx.repo
sudo rm /etc/yum.repos.d/app-protect*.repo
4. 필수 종속성을 설치합니다.
sudo yum install ca-certificates wget
5. dependencies.repo 파일을 /etc/yum.repos.d에 다운로드합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/dependencies.repo
NGINX 오픈소스용
1. /etc/yum.repos.d/nginx.repo라는 이름의 파일을 생성하고 다음 내용을 추가합니다.
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2. /etc/yum.repos.d/app-protect-x-oss.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-oss]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-oss/centos/7/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo yum install app-protect-module-oss
GPG 키를 수락하라는 메시지가 표시되면, 지문이 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62와 일치하는지 확인하고 수락합니다.
NGINX Plus용
1. nginx-plus-7.4.repo NGINX Plus 리포지토리 파일을 /etc/yum.repos.d에 다운로드 합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nginx-plus-7.4.repo
2. /etc/yum.repos.d/app-protect-x-plus.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-plus]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-plus/centos/7/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo yum install app-protect-module-plus
2-5. RHEL 8.1+ / Oracle Linux 8.1+
NGINX 오픈소스 및 NGINX Plus 공통 단계
1. /etc/ssl/nginx 디렉토리를 생성합니다.
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt와 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드합니다.
3. /etc/yum.repos.d에서 이전에 다운로드된 NGINX 리포지토리 파일을 제거합니다.
sudo rm /etc/yum.repos.d/nginx.repo
sudo rm /etc/yum.repos.d/app-protect*.repo
4. 필수 종속성을 설치합니다.
sudo dnf install ca-certificates wget
5. dependencies.repo 파일을 /etc/yum.repos.d에 다운로드 합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/dependencies.repo
NGINX 오픈소스용
1. /etc/yum.repos.d/nginx.repo 파일을 생성하고 다음 내용을 추가합니다.
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/8/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2. /etc/yum.repos.d/app-protect-x-oss.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-oss]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-oss/centos/8/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo dnf install app-protect-module-oss
GPG 키를 수락하라는 메시지가 표시되면, 지문이 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62와 일치하는지 확인하고 수락합니다.
NGINX Plus용
1. nginx-plus-8.repo NGINX Plus 리포지토리 파일을 /etc/yum.repos.d에 다운로드 합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nginx-plus-8.repo
2. /etc/yum.repos.d/app-protect-x-plus.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-plus]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-plus/centos/8/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo dnf install app-protect-module-plus
2-6. RHEL 9
NGINX 오픈소스 및 NGINX Plus 공통 단계
1. /etc/ssl/nginx 디렉토리를 생성합니다.
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt와 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드합니다.
3. /etc/yum.repos.d에서 이전에 다운로드된 NGINX 리포지토리 파일을 제거합니다.
sudo rm /etc/yum.repos.d/nginx.repo
sudo rm /etc/yum.repos.d/app-protect*.repo
4. 필수 종속성을 설치합니다.
sudo dnf install ca-certificates wget
5. dependencies.repo 파일을 /etc/yum.repos.d에 다운로드 합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/dependencies.repo
NGINX 오픈소스용
1. /etc/yum.repos.d/nginx.repo 파일을 생성하고 다음 내용을 추가합니다.
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/9/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
2. /etc/yum.repos.d/app-protect-x-oss.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-oss]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-oss/centos/9/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo dnf install app-protect-module-oss
GPG 키를 수락하라는 메시지가 표시되면, 지문이 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62와 일치하는지 확인하고 수락합니다.
NGINX Plus용
1. plus-9.repo NGINX Plus 리포지토리 파일을 /etc/yum.repos.d에 다운로드 합니다.
sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/plus-9.repo
2. /etc/yum.repos.d/app-protect-x-plus.repo라는 이름의 NGINX App Protect WAF 리포지토리 파일을 생성하고 다음 내용을 추가합니다.
[app-protect-x-plus]
name=nginx-app-protect repo
baseurl=https://pkgs.nginx.com/app-protect-x-plus/centos/9/$basearch/
sslclientcert=/etc/ssl/nginx/nginx-repo.crt
sslclientkey=/etc/ssl/nginx/nginx-repo.key
gpgcheck=0
enabled=1
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo dnf install app-protect-module-plus
2-7. Ubuntu 20.04 / Ubuntu 22.04
NGINX 오픈소스 및 NGINX Plus 공통 단계
1. /etc/ssl/nginx/ 디렉토리를 생성합니다.
sudo mkdir -p /etc/ssl/nginx
2. nginx-repo.crt와 nginx-repo.key 파일을 /etc/ssl/nginx/ 디렉토리에 업로드합니다.
3. 이전 NGINX 리포지토리 및 apt 구성 파일을 제거합니다.
sudo rm /etc/apt/sources.list.d/nginx*.list
sudo rm /etc/apt/sources.list.d/*app-protect*.list
sudo rm /etc/apt/apt.conf.d/90pkgs-nginx
4. 필수 패키지를 설치합니다.
sudo apt-get update && sudo apt-get install apt-transport-https lsb-release ca-certificates wget gnupg2 ubuntu-keyring
5. NGINX 서명 키를 다운로드하고 추가합니다.
wget -qO - https://cs.nginx.com/static/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null
6. apt 구성을 /etc/apt/apt.conf.d에 다운로드 합니다.
sudo wget -P /etc/apt/apt.conf.d https://cs.nginx.com/static/files/90pkgs-nginx
7. 다운로드한 파일에 올바른 키가 포함되어 있는지 확인합니다.
gpg --dry-run --quiet --no-keyring --import --import-options import-show /usr/share/keyrings/nginx-archive-keyring.gpg
출력 결과에는 다음과 같이 전체 fingerprint 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62가 포함되어야 합니다.
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key signing-key@nginx.com
fingerprint가 다르면 파일을 삭제합니다.
NGINX 오픈소스용
1. NGINX 오픈소스 리포지토리를 추가합니다.
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu lsb_release -cs nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
2. 배포 제공 패키지보다 NGINX 패키지를 우선하도록 리포지토리 고정 설정을 합니다.
echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
| sudo tee /etc/apt/preferences.d/99nginx
3. NGINX App Protect WAF 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect-x-oss/ubuntu lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect.list
4. NGINX App Protect WAF v5 패키지를 설치합니다.
sudo apt-get update
sudo apt-get install app-protect-module-oss
NGINX Plus용
1. NGINX Plus 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/plus/ubuntu lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-plus.list
2. NGINX App Protect WAF 리포지토리를 추가합니다.
printf "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://pkgs.nginx.com/app-protect-x-plus/ubuntu lsb_release -cs nginx-plus\n" | sudo tee /etc/apt/sources.list.d/nginx-app-protect.list
3. NGINX App Protect WAF 패키지를 설치합니다.
sudo apt-get update
sudo apt-get install app-protect-module-plus
3. NGINX App Protect WAF V5 를 위한 NGINX 구성
NGINX 설정에서 다음과 같이 구성합니다.
1. 메인 context에서 NGINX App Protect WAF 모듈을 로드합니다.
load_module modules/ngx_http_app_protect_module.so;
2. HTTP context에서 Enforcer 주소를 구성합니다.
app_protect_enforcer_address 127.0.0.1:50000;
3. HTTP/Server/Location context에서 NGINX App Protect WAF를 활성화합니다.
(proxy_pass/grpc_pass location에서만 NGINX App Protect WAF를 활성화하도록 합니다)
app_protect_enable on;
이 가이드에서 사용된 파일은 다음과 같습니다.
/etc/nginx/nginx.conf
user nginx;
worker_processes auto;
# NGINX App Protect WAF
load_module modules/ngx_http_app_protect_module.so;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
# NGINX App Protect WAF
app_protect_enforcer_address 127.0.0.1:50000;
include /etc/nginx/conf.d/*.conf;
}
/etc/nginx/conf.d/default.conf
server {
listen 80;
server_name domain.com;
proxy_http_version 1.1;
location / {
# NGINX App Protect WAF
app_protect_enable on;
client_max_body_size 0;
default_type text/html;
proxy_pass http://127.0.0.1:8080/;
}
}
server {
listen 8080;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
4. NGINX App Protect WAF V5 서비스 구성
4-1. NGINX App Protect WAF V5 Permission
NGINX App Protect WAF 서비스를 위해 디렉토리의 소유권을 올바르게 설정합니다. 여기서 101:101은 기본 UID/GID입니다.
1. 디렉토리 생성:
sudo mkdir -p /opt/app_protect/config /opt/app_protect/bd_config
2. 소유권 설정:
sudo chown -R 101:101 /opt/app_protect/
4-2. NGINX App Protect WAF V5 F5 컨테이너 레지스트리를 위한 Docker 설정
Docker를 F5 컨테이너 레지스트리(private-registry.nginx.com)와 상호작용 하도록 구성합니다.
1. 디렉토리 생성:
sudo mkdir -p /etc/docker/certs.d/private-registry.nginx.com
2. 인증서 파일 복사:
sudo cp /etc/docker/certs.d/private-registry.nginx.com/client.cert
sudo cp /etc/docker/certs.d/private-registry.nginx.com/client.key
참고:
참고: 인증서 파일의 확장자가 .crt에서 .cert로 변경되었음을 유의하세요.
4-3. NGINX App Protect WAF V5 Docker Compose 파일
다음 구성으로 docker-compose.yml 파일을 생성합니다.
1.0.0을 배포 중인 실제 릴리스 버전으로 교체하세요.
version: "3.9"
services:
waf-enforcer:
container_name: waf-enforcer
image: private-registry.nginx.com/nap/waf-enforcer:<version-tag>
environment:
- ENFORCER_PORT=50000
ports:
- "50000:50000"
volumes:
- /opt/app_protect/bd_config:/opt/app_protect/bd_config
networks:
- waf_network
restart: always
waf-config-mgr:
container_name: waf-config-mgr
image: private-registry.nginx.com/nap/waf-config-mgr:1.0.0
volumes:
- /opt/app_protect/bd_config:/opt/app_protect/bd_config
- /opt/app_protect/config:/opt/app_protect/config
- /etc/app_protect/conf:/etc/app_protect/conf
restart: always
network_mode: none
depends_on:
waf-enforcer:
condition: service_started
networks:
waf_network:
driver: bridge
참고:
일부 운영 체제에서는 SELinux 또는 AppArmor와 같은 보안 메커니즘이 기본적으로 활성화되어 있어, nginx 프로세스와 waf-config-mgr 및 waf-enforcer 컨테이너의 필요한 파일 접근을 차단할 수 있습니다. NGINX App Protect WAF v5가 보안을 손상시키지 않으면서 원활하게 작동하도록 하려면 맞춤형 SELinux 정책 또는 AppArmor 프로필을 설정하는 것을 고려하세요. 단기적인 문제 해결을 위해서는 permissive(SELinux) 또는 complain(AppArmor) 모드를 사용할 수 있지만, 이는 보안을 낮추므로 장기적으로 사용하는 것은 권장되지 않습니다.
5. NGINX App Protect WAF V5 Deployment 시작
1. WAF 서비스를 시작하려면, docker-compose.yml 파일이 있는 디렉토리로 이동하여 다음 명령을 실행합니다.
sudo docker compose up -d
2. NGINX를 시작하려면, 다음 명령을 실행합니다.
sudo nginx
3. Enforcer 기능을 확인하려면, 다음 요청이 거부되는지 확인합니다.
curl "localhost/<script>"
6. Policy 및 Logging Profile 번들 사용
이 파일들은 waf-config-mgr 컨테이너에서 접근할 수 있어야 합니다.
가정: 호스트 머신의 번들 파일이 /bundles 디렉토리에 있습니다. Docker Compose 구성: docker-compose.yml 파일에서 waf-config-mgr 서비스 아래에 볼륨 마운트를 추가하여 호스트 디렉토리 /bundles를 컨테이너 내부의 동일한 경로와 연결합니다.
…
waf-config-mgr:
container_name: waf-config-mgr
image: "private-registry.nginx.com/nap/waf-config-mgr:1.0.0"
volumes:
- /bundles:/bundles # 호스트 디렉토리를 컨테이너에 마운트
- … # 기존 볼륨 마운트
이 볼륨 마운트를 설정하면 번들 파일을 NGINX 구성에서 /bundles 디렉토리를 사용하여 참조할 수 있습니다.
app_protect_policy_file /bundles/custom_policy.tgz;
app_protect_security_log /bundles/custom_logging_profile.tgz syslog:server=localhost:5514;
NGINX App Protect WAF를 배포한 후, NGINX App Protect WAF Compiler를 사용하여 사용자 정의 정책과 로그 프로필을 적용하는 방법을 학습하세요.
7. NGINX 및 NGINX App Protect WAF V5 모듈 삭제
Docker 배포를 중지하고 NGINX 패키지를 제거합니다.
7-1. Docker Deployment 중단
WAF 서비스를 중지하려면 docker-compose.yml 파일이 있는 디렉토리로 이동하여 다음 명령을 실행합니다.
sudo docker compose stop -d
7-2. Alpine Linux 3.16 / Alpine Linux 3.17
NGINX 오픈소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo apk del app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다
sudo apk del app-protect-module-plus
7-3. Amazon Linux 2
NGINX 오픈 소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo yum remove app-protect-module-oss
sudo apt-get remove nginx=1.25.4-1~`lsb_release -cs` app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo yum remove app-protect-module-plus
7-4. Debian 11 / Debian 12
NGINX 오픈 소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo apt-get remove app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo apt-get remove app-protect-module-plus
7-5. RHEL 7.4+ / CentOS 7.4+
NGINX 오픈 소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo yum remove app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo yum remove app-protect-module-plus
7-6. RHEL 8.1+ / Oracle Linux 8.1+
NGINX 오픈 소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo dnf remove app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo dnf remove app-protect-module-plus
7-7. RHEL 9
NGINX 오픈 소스용 NGINX App Protect WAF 패키지를 제거합니다.
sudo dnf remove app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo dnf remove app-protect-module-plus
7-8. Ubuntu 20.04 / Ubuntu 22.04
shell코드 복사sudo apt-get remove app-protect-module-oss
NGINX Plus용 NGINX App Protect WAF 패키지를 제거합니다.
sudo apt-get remove app-protect-module-plus

NGINX App Protect WAF에 관심이 있으시거나 도입을 고려하고 계신가요? 지금 NGINX STORE에 문의하여 다양한 사용 사례에 대해 상담 받아볼 수 있습니다.