2025-01-28 22:40:56 +01:00
|
|
|
# Nginx WAF Rules
|
|
|
|
|
# Automatically generated from OWASP rules.
|
|
|
|
|
# Include this file inside server block
|
|
|
|
|
|
|
|
|
|
# WAF rules
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_xss) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_lfi) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_rfi) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_java) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_fixation) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_attack) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_enforcement) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_initialization) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_exceptions) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_php) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_leakages) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_generic) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_sql) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_evaluation) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_sqli) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_rce) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_iis) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-03 00:26:12 +00:00
|
|
|
if ($waf_block_shells) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-02 00:27:06 +00:00
|
|
|
if ($waf_block_correlation) {
|
2025-01-28 22:40:56 +01:00
|
|
|
return 403;
|
|
|
|
|
# Log the blocked request (optional)
|
|
|
|
|
# access_log /var/log/nginx/waf_blocked.log;
|
|
|
|
|
}
|
|
|
|
|
|