From 49391733b8a869110e1e5ba5d1e647adff45ce9a Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Tue, 2 Dec 2025 16:00:31 +0000 Subject: [PATCH 01/21] fixed nginx conf --- content/waf/configure/nginx-features.md | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 60e763138..0bcfba2b8 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -35,22 +35,15 @@ The following example demonstrates the general rule: {{< tabs name="subrequest-example" >}} -{{% tab name="nginx.js" %}} +{{% tab name="nginx.conf" %}} ```nginx user nginx; -worker_processes 4; -#daemon off; +worker_processes auto; load_module modules/ngx_http_app_protect_module.so; load_module modules/ngx_http_js_module.so; -error_log /var/log/nginx/error.log warn; - -events { - worker_connections 65536; -} - http { include /etc/nginx/mime.types; default_type application/octet-stream; From 95227b5b550754ad4e21bd05c8317f451282d592 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Tue, 2 Dec 2025 16:56:14 +0000 Subject: [PATCH 02/21] fix: changed the order --- content/waf/configure/nginx-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 0bcfba2b8..6a25b7886 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -26,10 +26,10 @@ F5 WAF for NGINX will secure and inspect direct client-facing requests, but will This applies to: +* njs (r.subrequest) * Client authorization (auth_request) * Mirror (mirror) * SSI (virtual include) -* njs (r.subrequest) The following example demonstrates the general rule: From ca3a9240ca02ae8a47418b8c009d06cde720fb19 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Wed, 3 Dec 2025 09:48:10 +0000 Subject: [PATCH 03/21] doc: change the format --- content/waf/configure/nginx-features.md | 143 ++++++++++++++---------- 1 file changed, 82 insertions(+), 61 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 6a25b7886..1fc1c44c5 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -11,27 +11,29 @@ nd-content-type: reference # Agent, N4Azure, NIC, NIM, NGF, NAP-DOS, NAP-WAF, NGINX One, NGINX+, Solutions, Unit nd-product: NAP-WAF --- - -This document shows example of how to modify your NGINX configuration to enable F5 WAF for NGINX features. +This document shows examples of how to modify your NGINX configuration to enable F5 WAF for NGINX features. It is intended as a reference for small, self-contained examples of how F5 WAF for NGINX can be configured. -Modules requiring the _Range_ header (Such as _Slice_) are unsupported in a scope which enables F5 WAF for NGINX. The examples below work around the contraints of these modules. +Important constraints when F5 WAF for NGINX is enabled: + +- Subrequest-based modules (NGINX modules that create internal HTTP subrequests) are not inspected in any scope block where __app_protect_enable on__ is set. F5 WAF for NGINX inspects only direct, client-facing HTTP requests. +- Modules that require the HTTP Range header are not supported in the same configuration scope as __app_protect_enable on__. Place Range-dependent configuration in a server or location block without F5 WAF for NGINX enabled. For additional information on configuring NGINX, you should view the [NGINX documentation]({{< ref "/nginx/" >}}). -## Internal subrequests +## Subrequest-based modules -F5 WAF for NGINX will secure and inspect direct client-facing requests, but will not inspect internal subrequests triggered by modules. +F5 WAF for NGINX inspects direct client-facing requests, but does not inspect internal subrequests generated by subrequest-based modules. -This applies to: +Examples of subrequest-based modules: * njs (r.subrequest) * Client authorization (auth_request) * Mirror (mirror) * SSI (virtual include) -The following example demonstrates the general rule: +### Example {{< tabs name="subrequest-example" >}} @@ -41,6 +43,10 @@ The following example demonstrates the general rule: user nginx; worker_processes auto; +events { + worker_connections 1024; +} + load_module modules/ngx_http_app_protect_module.so; load_module modules/ngx_http_js_module.so; @@ -125,59 +131,11 @@ Your support ID is: 123456789 [Go Back] ``` -## Static location - -```nginx -load_module modules/ngx_http_app_protect_module.so; - -http { - server { - listen 127.0.0.1:8080; - server_name localhost; - - location / { - app_protect_enable on; - proxy_pass http://127.0.0.1:8080/proxy/$request_uri; - } - - location /proxy { - default_type text/html; - return 200 "Hello! I got your URI request - $request_uri\n"; - } - } -} -``` - -## Range - -```nginx -load_module modules/ngx_http_app_protect_module.so; - -http { +### Additional subrequest-based examples - server { - listen 127.0.0.1:8080; - server_name localhost; +These examples show other subrequest-based modules. In each case, internal subrequests are not inspected by WAF. - location / { - app_protect_enable on; - proxy_pass http://127.0.0.1:8081$request_uri; - } - } - - server { - listen 127.0.0.1:8081; - server_name localhost; - - location / { - proxy_pass http://1.2.3.4$request_uri; - proxy_force_ranges on; - } - } -} -``` - -## Slice +#### Slice ```nginx load_module modules/ngx_http_app_protect_module.so; @@ -206,7 +164,7 @@ http { } ``` -## Mirror +#### Mirror ```nginx load_module modules/ngx_http_app_protect_module.so; @@ -231,7 +189,7 @@ http { } ``` -## njs +#### njs ```nginx load_module modules/ngx_http_app_protect_module.so; @@ -261,7 +219,7 @@ http { } ``` -## Client authorization +#### Client authorization ```nginx load_module modules/ngx_http_app_protect_module.so; @@ -290,4 +248,67 @@ http { } } } +``` + +## Range header–dependent modules + +Features that add or depend on the HTTP Range header are unsupported in the same scope as __app_protect_enable__ on. Place Range-dependent logic in a separate scope that does not enable F5 WAF for NGINX, and have the F5 WAF for NGINX enable frontend proxy to that backend. + +Examples of Range-dependent features: + +- Static location +- Range + +### Additional range-based examples + +### Static location + +```nginx +load_module modules/ngx_http_app_protect_module.so; + +http { + server { + listen 127.0.0.1:8080; + server_name localhost; + + location / { + app_protect_enable on; + proxy_pass http://127.0.0.1:8080/proxy/$request_uri; + } + + location /proxy { + default_type text/html; + return 200 "Hello! I got your URI request - $request_uri\n"; + } + } +} +``` + +### Range + +```nginx +load_module modules/ngx_http_app_protect_module.so; + +http { + + server { + listen 127.0.0.1:8080; + server_name localhost; + + location / { + app_protect_enable on; + proxy_pass http://127.0.0.1:8081$request_uri; + } + } + + server { + listen 127.0.0.1:8081; + server_name localhost; + + location / { + proxy_pass http://1.2.3.4$request_uri; + proxy_force_ranges on; + } + } +} ``` \ No newline at end of file From d61c323054c18cfeaf716166a0b8488bb27938d3 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Wed, 3 Dec 2025 13:15:32 +0000 Subject: [PATCH 04/21] fix header --- content/waf/configure/nginx-features.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 1fc1c44c5..5a59f7455 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -261,7 +261,7 @@ Examples of Range-dependent features: ### Additional range-based examples -### Static location +#### Static location ```nginx load_module modules/ngx_http_app_protect_module.so; @@ -284,7 +284,7 @@ http { } ``` -### Range +#### Range ```nginx load_module modules/ngx_http_app_protect_module.so; From 2abfda93756cdf5d26b76745afc3d100673b6187 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Wed, 3 Dec 2025 13:39:11 +0000 Subject: [PATCH 05/21] added back slice --- content/waf/configure/nginx-features.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 5a59f7455..186a210d1 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -28,10 +28,10 @@ F5 WAF for NGINX inspects direct client-facing requests, but does not inspect in Examples of subrequest-based modules: -* njs (r.subrequest) -* Client authorization (auth_request) -* Mirror (mirror) -* SSI (virtual include) +* njs +* Client authorization +* Slice +* Mirror ### Example From 5d43bb490bf95b1f4f65bd8a2eff7a5f431bf830 Mon Sep 17 00:00:00 2001 From: dkleinF5 <135969067+dkleinF5@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:46:48 +0200 Subject: [PATCH 06/21] Update content/waf/configure/nginx-features.md Co-authored-by: yar --- content/waf/configure/nginx-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 186a210d1..4ebd525d0 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -273,7 +273,7 @@ http { location / { app_protect_enable on; - proxy_pass http://127.0.0.1:8080/proxy/$request_uri; + proxy_pass http://127.0.0.1:8080/proxy/$request_uri; } location /proxy { From e729539cb6d3efb90c5225cc9e4a03994bb5ab56 Mon Sep 17 00:00:00 2001 From: dkleinF5 <135969067+dkleinF5@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:46:55 +0200 Subject: [PATCH 07/21] Update content/waf/configure/nginx-features.md Co-authored-by: yar --- content/waf/configure/nginx-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 4ebd525d0..b820ea25f 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -306,7 +306,7 @@ http { server_name localhost; location / { - proxy_pass http://1.2.3.4$request_uri; + proxy_pass http://1.2.3.4$request_uri; proxy_force_ranges on; } } From ab30a55677c6c0f9fd5a406502d4ed0397cdf49a Mon Sep 17 00:00:00 2001 From: dkleinF5 <135969067+dkleinF5@users.noreply.github.com> Date: Wed, 3 Dec 2025 15:47:02 +0200 Subject: [PATCH 08/21] Update content/waf/configure/nginx-features.md Co-authored-by: yar --- content/waf/configure/nginx-features.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index b820ea25f..14f05a55c 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -297,7 +297,7 @@ http { location / { app_protect_enable on; - proxy_pass http://127.0.0.1:8081$request_uri; + proxy_pass http://127.0.0.1:8081$request_uri; } } From 4a636167a88680b0fe42610cc019e5245c7d86d3 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Wed, 3 Dec 2025 13:49:43 +0000 Subject: [PATCH 09/21] added more space by proxy pass --- content/waf/configure/nginx-features.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 14f05a55c..99b3cc922 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -64,7 +64,7 @@ http { app_protect_enable on; location / { - proxy_pass http://127.0.0.1:8080/foo/$request_uri; + proxy_pass http://127.0.0.1:8080/foo/$request_uri; } } server { @@ -147,7 +147,7 @@ http { location / { app_protect_enable on; - proxy_pass http://127.0.0.1:8081$request_uri; + proxy_pass http://127.0.0.1:8081$request_uri; } } @@ -156,7 +156,7 @@ http { server_name localhost; location / { - proxy_pass http://1.2.3.4$request_uri; + proxy_pass http://1.2.3.4$request_uri; slice 2; proxy_set_header Range $slice_range; } @@ -204,7 +204,7 @@ http { location / { app_protect_enable on; - proxy_pass http://127.0.0.1:8081$request_uri; + proxy_pass http://127.0.0.1:8081$request_uri; } } @@ -231,10 +231,10 @@ http { location / { auth_request /scan; - proxy_pass http://localhost:8888; + proxy_pass http://localhost:8888; } location /scan { - proxy_pass http://localhost:8081$request_uri; + proxy_pass http://localhost:8081$request_uri; } } @@ -244,7 +244,7 @@ http { location /scan { app_protect_enable on; - proxy_pass http://localhost:8888; + proxy_pass http://localhost:8888; } } } @@ -273,7 +273,7 @@ http { location / { app_protect_enable on; - proxy_pass http://127.0.0.1:8080/proxy/$request_uri; + proxy_pass http://127.0.0.1:8080/proxy/$request_uri; } location /proxy { From 7f479f83533e149d9f6f84f0e58279e8a2664945 Mon Sep 17 00:00:00 2001 From: Daniel Klein Date: Wed, 3 Dec 2025 14:00:55 +0000 Subject: [PATCH 10/21] removed 4th level header --- content/waf/configure/nginx-features.md | 240 ++++++++++++------------ 1 file changed, 117 insertions(+), 123 deletions(-) diff --git a/content/waf/configure/nginx-features.md b/content/waf/configure/nginx-features.md index 99b3cc922..077ee2a93 100644 --- a/content/waf/configure/nginx-features.md +++ b/content/waf/configure/nginx-features.md @@ -28,114 +28,12 @@ F5 WAF for NGINX inspects direct client-facing requests, but does not inspect in Examples of subrequest-based modules: -* njs -* Client authorization * Slice +* Client authorization * Mirror +* njs -### Example - -{{< tabs name="subrequest-example" >}} - -{{% tab name="nginx.conf" %}} - -```nginx -user nginx; -worker_processes auto; - -events { - worker_connections 1024; -} - -load_module modules/ngx_http_app_protect_module.so; -load_module modules/ngx_http_js_module.so; - -http { - include /etc/nginx/mime.types; - default_type application/octet-stream; - sendfile on; - keepalive_timeout 65; - js_import main from example.js; - - server { - listen 80; - server_name localhost; - proxy_http_version 1.1; - app_protect_enable on; - - location / { - proxy_pass http://127.0.0.1:8080/foo/$request_uri; - } - } - server { - listen 127.0.0.1:8080; - server_name localhost; - proxy_http_version 1.1; - - location /foo { - js_content main.fetch_subrequest; - } - - location / { - internal; - return 200 "Hello! I got your URI request - $request_uri\n"; - } - } -} -``` - -{{% /tab %}} - -{{% tab name="example.js" %}} - -```js -async function fetch_subrequest(r) { - let reply = await r.subrequest('/