Skip to content

Commit f5de946

Browse files
authored
feat: add IP intelligence (new) (#622)
1 parent dfc25ee commit f5de946

File tree

5 files changed

+112
-11
lines changed

5 files changed

+112
-11
lines changed

content/includes/nap-waf/config/common/ip-intelligence-conf.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33

44
As of NAP version 4.15.0 (for NAP V4 deployments), and NAP version 5.7.0 (for NAP V5 deployments), NGINX App Protect WAF includes a new feature named IP Intelligence. This features allows customizing the enforcement based on the source IP of the request to limit access from IP addresses with questionable reputation. Please note that:
5-
- The IP intelligence feature is disabled by default and needs to be explicitly enabled and configured in the policy.
6-
- The package `app-protect-ip-intelligence` needs to be installed (for NAP V4 deployments), or the IP Intelligence image deployed (for NAP V5 deployments), before configuring and using the feature. This package installs the client that downloads and updates the database required for enforcing IP Intelligence.
5+
- The IP intelligence feature is **disabled** by default and needs to be explicitly enabled and configured in the policy.
6+
- The package `app-protect-ip-intelligence` must be installed (for NAP V4 deployments), or the IP Intelligence image deployed (for NAP V5 deployments), before configuring and using the feature. This package installs the client that downloads and updates the database required for enforcing IP Intelligence.
77

88
After installing the package or image, enable the feature in the following two places in the policy:
9-
1. By enabling the corresponding violation in the violation list: `"name": "VIOL_MALICIOUS_IP"` and assigning the required `block` and `alarm` values to the violation.
9+
1. By enabling the corresponding violation in the violation list: `"name": "VIOL_MALICIOUS_IP"` and assigning the appropriate `block` and `alarm` values to the violation.
1010

1111
2. By enabling the featue in the corresponding IP Intelligence JSON section: `"ip-intelligence": {"enabled": true}` and define actions for the IP Intelligence categories listed below.
1212

@@ -99,6 +99,7 @@ An example policy where both elements are enabled, and all the IP intelligence c
9999
}
100100
}
101101
```
102+
102103
This policy will basically block `"block": true` all IP addresses that are part of any threat category and add a log entry `"alarm": true` for the transaction.
103104

104105
The IP address database is managed by an external provider and is constantly updated (every 1 minute by default). The database also categorizes IP addresses into one or more threat categories. These are the same categories that can be configured individually in the IP intelligence section:
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
If the deployment intends to use the IP intelligence Feature (avaiable from version 5.7.0), then the IP intelligence container needs to be added to the deployment in the docker compose file.
2+
3+
Modify the original `docker-compose.yml` file to include the additional IP Intelligence container:
4+
5+
```yaml
6+
services:
7+
waf-enforcer:
8+
container_name: waf-enforcer
9+
image: private-registry.nginx.com/nap/waf-enforcer:5.7.0
10+
environment:
11+
- ENFORCER_PORT=50000
12+
ports:
13+
- "50000:50000"
14+
volumes:
15+
- /opt/app_protect/bd_config:/opt/app_protect/bd_config
16+
- /var/IpRep:/var/IpRep
17+
networks:
18+
- waf_network
19+
restart: always
20+
user: "101:101"
21+
depends_on:
22+
- waf-ip-intelligence
23+
24+
waf-config-mgr:
25+
container_name: waf-config-mgr
26+
image: private-registry.nginx.com/nap/waf-config-mgr:5.7.0
27+
volumes:
28+
- /opt/app_protect/bd_config:/opt/app_protect/bd_config
29+
- /opt/app_protect/config:/opt/app_protect/config
30+
- /etc/app_protect/conf:/etc/app_protect/conf
31+
restart: always
32+
user: "101:101"
33+
network_mode: none
34+
depends_on:
35+
waf-enforcer:
36+
condition: service_started
37+
38+
waf-ip-intelligence:
39+
container_name: waf-ip-intelligence
40+
image: private-registry.nginx.com/nap/waf-ip-intelligence:5.7.0
41+
volumes:
42+
- /var/IpRep:/var/IpRep
43+
networks:
44+
- waf_network
45+
restart: always
46+
user: "101:101"
47+
48+
networks:
49+
waf_network:
50+
driver: bridge
51+
```
52+
53+
Notes:
54+
- Replace `waf-config-mgr`, `waf-enforcer` and `waf-ip-intelligence` tags with the actual release version tag you are deploying. We are using version 5.7.0 for this example deployment.
55+
- By default, the containers `waf-config-mgr`, `waf-enforcer` and `waf-ip-intelligence` operate with the user and group IDs set to 101:101. Ensure that the folders and files are accessible to these IDs.
56+
57+
Before creating the deployment in docker compose, create the required directories:
58+
59+
```shell
60+
sudo mkdir -p /opt/app_protect/config /opt/app_protect/bd_config /var/IpRep
61+
```
62+
63+
Then set correct ownership:
64+
65+
```shell
66+
sudo chown -R 101:101 /opt/app_protect/ /var/IpRep
67+
```

content/nap-waf/v4/admin-guide/install.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ RUN --mount=type=secret,id=nginx-crt,dst=/etc/apk/cert.pem,mode=0644 \
10791079
# Only use if you want to install and use the IP intelligence feature:
10801080
RUN --mount=type=secret,id=nginx-crt,dst=/etc/apk/cert.pem,mode=0644 \
10811081
--mount=type=secret,id=nginx-key,dst=/etc/apk/cert.key,mode=0644 \
1082-
apk update && apk app-protect-ip-intelligence
1082+
apk update && apk add app-protect-ip-intelligence
10831083
10841084
# Forward request logs to Docker log collector:
10851085
RUN ln -sf /dev/stdout /var/log/nginx/access.log \
@@ -1743,7 +1743,7 @@ On a host with access to the NGINX App Protect WAF repository:
17431743
yum install --downloadonly --downloaddir=/etc/packages/ app-protect
17441744
```
17451745
1746-
Only use if you want to install and use the IP intelligence feature:
1746+
Only use if you want to install and use the IP intelligence feature:
17471747
17481748
```shell
17491749
yum install --downloadonly --downloaddir=/etc/packages/ app-protect-ip-intelligence
@@ -1777,7 +1777,7 @@ On an offline host:
17771777
yum -y install app-protect
17781778
```
17791779
1780-
Only use if you want to install and use the IP intelligence feature:
1780+
Only use if you want to install and use the IP intelligence feature:
17811781
17821782
```shell
17831783
yum -y install app-protect-ip-intelligence
@@ -1797,7 +1797,8 @@ On a host with access to the NGINX App Protect WAF repository:
17971797
apt-get update
17981798
for i in $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-replaces --no-enhances app-protect | grep "^\w" | sort -u); do apt-get download $i 2>>errors.txt; done
17991799
```
1800-
Only use if you want to install and use the IP intelligence feature:
1800+
1801+
Only use if you want to install and use the IP intelligence feature:
18011802
18021803
```shell
18031804
cd /etc/packages/
@@ -1818,7 +1819,8 @@ On an offline host:
18181819
apt-get update
18191820
apt-get install -y app-protect
18201821
```
1821-
Only use if you want to install and use the IP intelligence feature:
1822+
1823+
Only use if you want to install and use the IP intelligence feature:
18221824
18231825
```shell
18241826
apt-get install -y app-protect-ip-intelligence

content/nap-waf/v5/admin-guide/deploy-on-docker.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,11 @@ volumes:
346346
```
347347
348348
349+
### Docker Compose File with IP Intelligence
350+
351+
{{< include "nap-waf/ip-intelligence.md" >}}
352+
353+
349354
### Docker Compose File with mTLS
350355
351356
To secure traffic between NGINX and App Protect Enforcer using mTLS, create a `docker-compose.yml` with the following configuration:
@@ -665,6 +670,11 @@ volumes:
665670
app_protect_config:
666671
app_protect_etc_config:
667672
```
673+
674+
#### Docker Compose File with IP Intelligence
675+
676+
{{< include "nap-waf/ip-intelligence.md" >}}
677+
668678
### Start Deployment
669679

670680
1. To start the NGINX and WAF services, navigate to the directory that contains the `docker-compose.yml` file and run:

content/nap-waf/v5/admin-guide/install.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,10 @@ networks:
294294
In some operating systems, security mechanisms like **SELinux** or **AppArmor** are enabled by default, potentially blocking necessary file access for the `nginx` process and `waf-config-mgr` and `waf-enforcer` containers. To ensure NGINX App Protect WAF v5 operates smoothly without compromising security, consider setting up a custom SELinux policy or AppArmor profile. For short-term troubleshooting, you may use `permissive` (SELinux) or `complain` (AppArmor) mode to avoid these restrictions, but keep in mind that this lowers security and isn't advised for prolonged use.
295295
{{< /note >}}
296296

297+
### Docker Compose File with IP Intelligence
298+
299+
{{< include "nap-waf/ip-intelligence.md" >}}
300+
297301
## Start the Deployment
298302

299303
1. To start the WAF services, navigate to the directory that contains the `docker-compose.yml` file and run:
@@ -897,18 +901,25 @@ docker pull private-registry.nginx.com/nap/waf-enforcer:5.2.0
897901
docker pull private-registry.nginx.com/nap/waf-config-mgr:5.2.0
898902
```
899903

904+
If IP Intelligence feature is to be used on the deployment, download the `waf-ip-intelligence` as well:
905+
906+
```shell
907+
docker pull private-registry.nginx.com/nap/waf-ip-intelligence:5.2.0
908+
```
909+
900910
#### Saving and Transferring Images
901911

902-
1. Save the `waf-enforcer` docker image:
912+
1. Save the `waf-enforcer` and `waf-config-mgr` docker images:
903913

904914
```shell
905915
docker save -o waf-enforcer.tar waf-enforcer:5.2.0
916+
docker save -o waf-config-mgr.tar waf-config-mgr:5.2.0
906917
```
907918

908-
2. Save the `waf-config-mgr` docker image:
919+
2. If IP Intelligence feature is to be used on the deployment, save the `waf-ip-intelligence` docker image:
909920

910921
```shell
911-
docker save -o waf-config-mgr.tar waf-config-mgr:5.2.0
922+
docker save -o waf-ip-intelligence.tar waf-ip-intelligence:5.2.0
912923
```
913924

914925
3. Transfer the tar files from the online machine to the offline/air-gapped machine:
@@ -920,6 +931,12 @@ docker pull private-registry.nginx.com/nap/waf-config-mgr:5.2.0
920931
docker load -i waf-config-mgr.tar
921932
```
922933

934+
5. If IP Intelligence feature is to be used on the deployment, on the offline machine load the docker images:
935+
936+
```shell
937+
docker load -i waf-ip-intelligence.tar
938+
```
939+
923940
#### Docker Compose File
924941

925942
Create a `docker-compose.yml` with the following configuration on the offline machine:
@@ -963,6 +980,10 @@ networks:
963980
In some operating systems, security mechanisms like **SELinux** or **AppArmor** are enabled by default, potentially blocking necessary file access for the `nginx` process and `waf-config-mgr` and `waf-enforcer` containers. To ensure NGINX App Protect WAF v5 operates smoothly without compromising security, consider setting up a custom SELinux policy or AppArmor profile. For short-term troubleshooting, you may use `permissive` (SELinux) or `complain` (AppArmor) mode to avoid these restrictions, but keep in mind that this lowers security and isn't advised for prolonged use.
964981
{{< /note >}}
965982

983+
#### Docker Compose File with IP Intelligence
984+
985+
{{< include "nap-waf/ip-intelligence.md" >}}
986+
966987
### Start the Deployment
967988

968989
1. To start the WAF services, navigate to the directory that contains the `docker-compose.yml` file and run:

0 commit comments

Comments
 (0)