NGINX App Protect WAF 설치
이 포스트에서는 호스트 기반 NGINX 설정에서 NGINX App Protect WAF v5 설치 방법을 설명합니다.
목차
1. 전제 조건
2. NGINX 및 NGINX App Protect WAF 모듈 설치
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 설정
4. WAF 서비스 설정
4-1. 권한 설정
4-2. F5 Container Registry용 Docker 설정
4-3. Docker Compose 파일
5. 배포 시작
6. 정책 및 로깅 프로필 번들 사용
7. NGINX 및 NGINX App Protect WAF 모듈 제거
7-1. Docker 배포 중지
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. 전제 조건
2. NGINX 및 NGINX App Protect WAF 모듈 설치
1. 이전에 설치된 NGINX 패키지가 있는 경우, 구성 및 로그 파일을 백업하십시오.
$ sudo cp -a /etc/nginx /etc/nginx-plus-backup
$ sudo cp -a /var/log/nginx /var/log/nginx-plus-backup
2. MyF5 Customer Portal에 로그인하고 nginx-repo.crt 와 nginx-repo.key 파일을 다운로드합니다.
3. 이전 NGINX App Protect 패키지가 설치되어 있는 경우 반드시 제거하십시오.
4. 사용 중인 운영 체제에 따라 아래 단계를 따르십시오.
Note:
nginx 혹은 nginx-plus가 설치 되어있지 않은 경우, 의존성으로 자동적으로 설치됩니다.
2-1. Alpine Linux 3.16 / Alpine Linux 3.17
NGINX Open Source, 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 Open source
1. 메인라인 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 v5 apk 리포지토리를 추가합니다.
$ printf "https://pkgs.nginx.com/app-protect-x-oss/alpine/v`egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release`/main\n" | sudo tee -a /etc/apk/repositories
3. NGINX App Protect WAF v5 패키지를 설치 합니다.
$ sudo apk add app-protect-module-oss
NGINX Plus
1. NGINX Plus apk 리포지토리를 /etc/apk/repositoriec 파일에 추가합니다.
$ printf "https://pkgs.nginx.com/plus/alpine/v`egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release`/main\n" | sudo tee -a /etc/apk/repositories
2. NGINX App Protect WAF v5 apk 리포지토리를 추가합니다.
$ printf "https://pkgs.nginx.com/app-protect-x-plus/alpine/v`egrep -o '^[0-9]+\.[0-9]+' /etc/alpine-release`/main\n" | sudo tee -a /etc/apk/repositories
3. NGINX App Protect WAF v5 패키지를 설치 합니다.
$ sudo apk add app-protect-module-plus
2-2. Amazon Linux 2
NGINX Open Source, 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 Open Source
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 v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-oss.repo 이름으로 생성합니다.
[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
$ sudo apt-get install nginx=1.25.4-1~`lsb_release -cs` app-protect-module-oss
GPG 키를 승인하라는 메시지가 표시되면 지문이 573B FD6B 3D8F BC64 1079 A6AB ABF5 BD82 7BD9 BF62와 일치하는지 확인하고 일치하면 승인합니다.
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 v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-plus.repo 이름으로 생성합니다.
[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 v5 패키지를 설치 합니다.
$ sudo yum install app-protect-module-plus
2-3. Debian 11 / Debian 12
NGINX Open Source, 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 서명 키를 다운로드하고, 추가합니다.
$ 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
출력에는 다음과 같이 전체 지문 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62가 포함되어야 합니다.
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>
지문이 다를 경우 파일을 제거합니다.
NGINX Open Source
1. NGINX Open Source 리포지토리를 추가합니다.
$ 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. 배포판에서 제공하는 패키지보다 당사 패키지를 선호하도록 저장소 고정을 설정합니다.
$ 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 v5 리포지토리를 추가합니다.
$ 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 v5 리포지토리를 추가합니다.
$ 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 v5 패키지를 설치 합니다.
$ sudo apt-get update
$ sudo apt-get install app-protect-module-plus
2-4. RHEL 7.4+ / CentOS 7.4+
NGINX Open Source, 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 Open Source
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. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-oss.repo 이름으로 생성합니다.
[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 리포지토리 파일 nginx-plus-7.4.repo을 /etc/yum.repos.d에 다운로드합니다.
$ sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nginx-plus-7.4.repo
2. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-plus.repo 이름으로 생성합니다.
[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 v5 패키지를 설치 합니다.
$ sudo yum install app-protect-module-plus
2-5. RHEL 8.1+ / Oracle Linux 8.1+
NGINX Open Source, 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 Open Source
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. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-oss.repo 이름으로 생성합니다.
[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 리포지토리 파일 nginx-plus-8.repo을 /etc/yum.repos.d에 다운로드합니다.
$ sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/nginx-plus-8.repo
2. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-plus.repo 이름으로 생성합니다.
[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 v5 패키지를 설치 합니다.
sudo dnf install app-protect-module-plus
2-6. RHEL 9
NGINX Open Source, 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 Open Source
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. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-oss.repo 이름으로 생성합니다.
[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. NGINX Plus 리포지토리 파일 plus-9.repo을 /etc/yum.repos.d에 다운로드합니다.
$ sudo wget -P /etc/yum.repos.d https://cs.nginx.com/static/files/plus-9.repo
2. 다음 내용을 포함하는 NGINX App Protect WAF v5 리포지토리 파일을 /etc/yum.repos.d/app-protect-x-plus.repo 이름으로 생성합니다.
[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 v5 패키지를 설치 합니다.
$ sudo dnf install app-protect-module-plus
2-7. Ubuntu 20.04 / Ubuntu 22.04
NGINX Open Source, 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
출력에는 다음과 같이 전체 지문 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62가 포함되어야 합니다.
pub rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid nginx signing key <signing-key@nginx.com>
지문이 다를 경우 파일을 제거합니다.
NGINX Open Source
1. NGINX Open Source 리포지토리를 추가합니다.
$ 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. 배포판에서 제공하는 패키지보다 당사 패키지를 선호하도록 저장소 고정을 설정합니다.
$ 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 v5 리포지토리를 추가합니다.
$ 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 v5 리포지토리를 추가합니다.
$ 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 v5 패키지를 설치 합니다.
$ sudo apt-get update
$ sudo apt-get install app-protect-module-plus
3. NGINX 설정
nginx 구성에서:
1. 메인 컨텍스트에서 NGINX App Protect WAF v5 모듈을 불러옵니다.
load_module modules/ngx_http_app_protect_module.so;
2. http 컨텍스트에서 Enforcer 주소를 구성합니다.
app_protect_enforcer_address 127.0.0.1:50000;
3. http/server/location 컨텍스트에서 NGINX App Protect WAF를 활성화합니다.(NGINX App Protect WAF는 proxy_pass/grpc_pass location에서만 활성화해야 합니다.
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;
}
4. WAF 서비스 설정
4-1. 권한 설정
NGINX App Protect WAF v5 서비스를 위해 올바른 소유권으로 디렉토리를 설정합니다. 101:101은 기본 UID/GID입니다.
디렉토리 생성:
$ sudo mkdir -p /opt/app_protect/config /opt/app_protect/bd_config
소유권 설정:
$ sudo chown -R 101:101 /opt/app_protect/
4-2. F5 Container Registry용 Docker 설정
private-registry.nginx.com에서 F5 Container Registry와 상호작용을 하도록 Docker를 구성합니다.
$ sudo mkdir -p /etc/docker/certs.d/private-registry.nginx.com
$ sudo cp <path-to-your-nginx-repo.crt> /etc/docker/certs.d/private-registry.nginx.com/client.cert
$ sudo cp <path-to-your-nginx-repo.key> /etc/docker/certs.d/private-registry.nginx.com/client.key
Note:
인증서 파일의 확장자가 .crt에서 .cert로 변경되었습니다.
4-3. Docker Compose 파일
다음 구성으로 docer-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
Note:
일부 운영 체제에서는 SELinux 또는 AppArmor 와 같은 보안 메커니즘이 기본적으로 활성화되어 nginx 프로세스와 waf-config-mgr, waf-enforcer 컨테이너의 필요한 파일 접근을 차단할 수 있습니다. NGINX App Protect WAF v5가 보안을 침해하지 않으면서 원활하게 작동하도록 하려면, 사용자 정의 SELinux 정책이나 AppArmor 프로필을 설정하는 것을 고려해 보세요. 단기적인 문제 해결을 위해 permissive(SELinux) 또는 complain(AppArmor) 모드를 사용하여 이러한 제한을 피할 수 있지만, 이는 보안을 약화하므로 장기간 사용하는 것은 권장되지 않습니다.
5. 배포 시작
1. WAF 서비스를 시작하기 위해, docker-compose.yml 파일이 포함된 디렉토리로 이동하여 다음 명령어를 실행합니다.
$ sudo docker compose up -d
2. NGINX를 시작하기 위해, 다음 명령어를 실행합니다.
$ sudo nginx
3. 실행을 확인하기 위해, 다음 요청이 거부되는 것을 확인합니다.
curl "localhost/<script>"
6. 정책 및 로깅 프로필 번들 사용
사용자 정의 정책 및 로깅 프로필 번들을 사용하려면 waf-config-mgr 컨테이너에서 이 파일들에 접근할 수 있어야 합니다.
1. 가정: 번들 파일이 호스트 시스템의 /bundles에 있습니다.
2. 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 # Mounting the host directory to the container
- ... #existing volume mounts
볼륨 마운트를 설정하면 /bundles 디렉터리를 사용하여 NGINX 구성 내에서 번들 파일을 참조할 수 있습니다.
예를 들어:
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 컴파일러를 활용하는 방법을 알아보세요 .
7. NGINX 및 NGINX App Protect WAF 모듈 제거
Docker 배포를 중지하고 NGINX 패키지를 제거합니다.
7-1. Docker 배포 중지
WAF 서비스를 중지하기 위해, docker-compose.yml 파일이 포함된 디렉토리로 이동하여 다음 명령어를 실행합니다.
$ sudo docker compose stop -d
7-2. Alpine Linux 3.16 / Alpine Linux 3.17
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apk del app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apk del app-protect-module-plus
7-3. Amazon Linux 2
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ 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 v5 패키지를 제거합니다:
$ sudo yum remove app-protect-module-plus
7-4. Debian 11 / Debian 12
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apt-get remove app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apt-get remove app-protect-module-plus
7-5. RHEL 7.4+ / CentOS 7.4+
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo yum remove app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo yum remove app-protect-module-plus
7-6. RHEL 8.1+ / Oracle Linux 8.1+
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo dnf remove app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo dnf remove app-protect-module-plus
7-7. RHEL 9
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo dnf remove app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo dnf remove app-protect-module-plus
7-8. Ubuntu 20.04 / Ubuntu 22.04
NGINX Open Source
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apt-get remove app-protect-module-oss
NGINX Plus
NGINX App Protect WAF v5 패키지를 제거합니다:
$ sudo apt-get remove app-protect-module-plus