Configure F5 WAF for NGINX
This guide explains how to configure the F5 WAF for NGINX security features.
To use F5 WAF for NGINX, apply the following changes to the NGINX config file.
- Load the F5 WAF for NGINX module on the main context:
load_module modules/ngx_http_app_protect_module.so;- Set the enforcer address:
app_protect_enforcer_address 127.0.0.1:50000;The app_protect_enforcer_address directive is a required directive for F5 WAF for NGINX to work and must match127.0.0.1:50000
- Enable F5 WAF for NGINX with the
app_protect_enabledirectives in the appropriate scope. Theapp_protect_enabledirective may be set in thehttp,server, andlocationcontexts.
It is recommended to have a basic policy enabled in the http or server context to process malicious requests in a more complete manner.
app_protect_enable on;- Configure the pre-defined policy to use with the
app_protect_policy_filedirective (either theapp_protect_default_policyorapp_protect_strict_policy).
app_protect_policy_file app_protect_strict_policy;Sample Config with F5 WAF for NGINX configured:
user nginx;
worker_processes auto;
worker_rlimit_nofile 8192;
pid /run/nginx/nginx.pid;
load_module modules/ngx_http_app_protect_module.so;
events {
worker_connections 4000;
}
error_log /var/log/nginx/error.log debug;
http {
access_log off;
server_tokens "";
app_protect_enforcer_address 127.0.0.1:50000;
server {
listen 80 default_server;
location / {
app_protect_enable on;
app_protect_policy_file app_protect_strict_policy;
proxy_pass http://127.0.0.1:80/proxy/$request_uri;
}
location /proxy {
default_type text/html;
return 200 "Hello World\n";
}
}
}