|
| 1 | +--- |
| 2 | +# We use sentence case and present imperative tone |
| 3 | +title: "Configure NGINX features with F5 WAF" |
| 4 | +# Weights are assigned in increments of 100: determines sorting order |
| 5 | +weight: 100 |
| 6 | +# Creates a table of contents and sidebar, useful for large documents |
| 7 | +toc: false |
| 8 | +# Types have a 1:1 relationship with Hugo archetypes, so you shouldn't need to change this |
| 9 | +nd-content-type: reference |
| 10 | +# Intended for internal catalogue and search, case sensitive: |
| 11 | +# Agent, N4Azure, NIC, NIM, NGF, NAP-DOS, NAP-WAF, NGINX One, NGINX+, Solutions, Unit |
| 12 | +nd-product: NAP-WAF |
| 13 | +--- |
| 14 | + |
| 15 | +This document shows example of how to modify your NGINX configuration to enable F5 WAF for NGINX features. |
| 16 | + |
| 17 | +It is intended as a reference for, small self-contained examples of how F5 WAF for NGINX is configured. |
| 18 | + |
| 19 | +Certain features do not work well with F5 NGINX, such as modules requiring _subrequest_ when calling or being called from a scope that contains `app_protect_enable on`. |
| 20 | + |
| 21 | +Modules requiring the _Range_ header (Such as _Slice_) are also unsupported in a scope which enables F5 WAF for NGINX. |
| 22 | + |
| 23 | +The examples below show work arounds for the limitations of these features. |
| 24 | + |
| 25 | +For information on configuring NGINX, you should view the [NGINX documentation]({{< ref "/nginx/" >}}). |
| 26 | + |
| 27 | +## Static location |
| 28 | + |
| 29 | +```nginx |
| 30 | +load_module modules/ngx_http_app_protect_module.so; |
| 31 | +
|
| 32 | +http { |
| 33 | + server { |
| 34 | + listen 127.0.0.1:8080; |
| 35 | + server_name localhost; |
| 36 | +
|
| 37 | + location / { |
| 38 | + app_protect_enable on; |
| 39 | + proxy_pass http://127.0.0.1:8080/proxy/$request_uri; |
| 40 | + } |
| 41 | +
|
| 42 | + location /proxy { |
| 43 | + default_type text/html; |
| 44 | + return 200 "Hello! I got your URI request - $request_uri\n"; |
| 45 | + } |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +## Ranges |
| 51 | + |
| 52 | +```nginx |
| 53 | +load_module modules/ngx_http_app_protect_module.so; |
| 54 | +
|
| 55 | +http { |
| 56 | +
|
| 57 | + server { |
| 58 | + listen 127.0.0.1:8080; |
| 59 | + server_name localhost; |
| 60 | +
|
| 61 | + location / { |
| 62 | + app_protect_enable on; |
| 63 | + proxy_pass http://127.0.0.1:8081$request_uri; |
| 64 | + } |
| 65 | + } |
| 66 | +
|
| 67 | + server { |
| 68 | + listen 127.0.0.1:8081; |
| 69 | + server_name localhost; |
| 70 | +
|
| 71 | + location / { |
| 72 | + proxy_pass http://1.2.3.4$request_uri; |
| 73 | + proxy_force_ranges on; |
| 74 | + } |
| 75 | + } |
| 76 | +} |
| 77 | +``` |
| 78 | + |
| 79 | +## Slice |
| 80 | + |
| 81 | +```nginx |
| 82 | +load_module modules/ngx_http_app_protect_module.so; |
| 83 | +
|
| 84 | +http { |
| 85 | + server { |
| 86 | + listen 127.0.0.1:8080; |
| 87 | + server_name localhost; |
| 88 | +
|
| 89 | + location / { |
| 90 | + app_protect_enable on; |
| 91 | + proxy_pass http://127.0.0.1:8081$request_uri; |
| 92 | + } |
| 93 | + } |
| 94 | +
|
| 95 | + server { |
| 96 | + listen 127.0.0.1:8081; |
| 97 | + server_name localhost; |
| 98 | +
|
| 99 | + location / { |
| 100 | + proxy_pass http://1.2.3.4$request_uri; |
| 101 | + slice 2; |
| 102 | + proxy_set_header Range $slice_range; |
| 103 | + } |
| 104 | + } |
| 105 | +} |
| 106 | +``` |
| 107 | + |
| 108 | +## Mirror |
| 109 | + |
| 110 | +```nginx |
| 111 | +load_module modules/ngx_http_app_protect_module.so; |
| 112 | +
|
| 113 | +http { |
| 114 | + log_format test $uri; |
| 115 | +
|
| 116 | + server { |
| 117 | + listen 127.0.0.1:8080; |
| 118 | + server_name localhost; |
| 119 | +
|
| 120 | + location / { |
| 121 | + app_protect_enable on; |
| 122 | + mirror /mirror; |
| 123 | + } |
| 124 | +
|
| 125 | + location /mirror { |
| 126 | + log_subrequest on; |
| 127 | + access_log test$args.log test; |
| 128 | + } |
| 129 | + } |
| 130 | +} |
| 131 | +``` |
| 132 | + |
| 133 | +## njs |
| 134 | + |
| 135 | +```nginx |
| 136 | +load_module modules/ngx_http_app_protect_module.so; |
| 137 | +load_module modules/ngx_http_js_module.so; |
| 138 | +
|
| 139 | +http { |
| 140 | + js_include service.js |
| 141 | +
|
| 142 | + server { |
| 143 | + listen 127.0.0.1:8080; |
| 144 | + server_name localhost; |
| 145 | +
|
| 146 | + location / { |
| 147 | + app_protect_enable on; |
| 148 | + proxy_pass http://127.0.0.1:8081$request_uri; |
| 149 | + } |
| 150 | + } |
| 151 | +
|
| 152 | + server { |
| 153 | + listen 127.0.0.1:8081; |
| 154 | + server_name localhost; |
| 155 | +
|
| 156 | + location / { |
| 157 | + js_content foo; |
| 158 | + } |
| 159 | + } |
| 160 | +} |
| 161 | +``` |
| 162 | + |
| 163 | +## Client authorization |
| 164 | + |
| 165 | +```nginx |
| 166 | +load_module modules/ngx_http_app_protect_module.so; |
| 167 | +
|
| 168 | +http { |
| 169 | + server { |
| 170 | + listen 127.0.0.1:8080; |
| 171 | + server_name localhost; |
| 172 | +
|
| 173 | + location / { |
| 174 | + auth_request /scan; |
| 175 | + proxy_pass http://localhost:8888; |
| 176 | + } |
| 177 | + location /scan { |
| 178 | + proxy_pass http://localhost:8081$request_uri; |
| 179 | + } |
| 180 | + } |
| 181 | +
|
| 182 | + server { |
| 183 | + listen 127.0.0.1:8081; |
| 184 | + server_name localhost; |
| 185 | +
|
| 186 | + location /scan { |
| 187 | + app_protect_enable on; |
| 188 | + proxy_pass http://localhost:8888; |
| 189 | + } |
| 190 | + } |
| 191 | +} |
| 192 | +``` |
0 commit comments