-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Generate Nginx WAF config with separate map and rule files
This commit modifies the script to output two files: - waf_maps.conf (for http block) - waf_rules.conf (for server block) to avoid conflicts and provide more flexibility. This update should fix the bugged nginx rules integration on existing setups: #8
- Loading branch information
1 parent
eaf5714
commit f1bae07
Showing
6 changed files
with
535 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,30 @@ | ||
# Nginx WAF Rule Snippets | ||
# Nginx WAF Configuration | ||
|
||
This directory contains Nginx WAF rule snippets generated from OWASP rules. | ||
You can include these snippets in your existing Nginx configuration to enhance security. | ||
This directory contains Nginx WAF configuration files generated from OWASP rules. | ||
You can include these files in your existing Nginx configuration to enhance security. | ||
|
||
## Usage | ||
1. Include the rule snippets in your `server` or `location` block: | ||
1. Include the `waf_maps.conf` file in your `nginx.conf` *inside the `http` block*: | ||
```nginx | ||
http { | ||
include /path/to/waf_patterns/nginx/waf_maps.conf; | ||
# ... other http configurations ... | ||
} | ||
``` | ||
2. Include the `waf_rules.conf` file in your `server` block: | ||
```nginx | ||
server { | ||
# Your existing configuration | ||
include /path/to/waf_patterns/nginx/*.conf; | ||
# ... other server configurations ... | ||
include /path/to/waf_patterns/nginx/waf_rules.conf; | ||
} | ||
``` | ||
2. Reload Nginx to apply the changes: | ||
3. Reload Nginx to apply the changes: | ||
```bash | ||
sudo nginx -t && sudo systemctl reload nginx | ||
``` | ||
|
||
## Notes | ||
- The rules use `map` directives for efficient pattern matching. | ||
- The rules use `map` directives for efficient pattern matching. The maps are defined in the `waf_maps.conf` file. | ||
- The rules (if statements) are defined in the `waf_rules.conf` file. | ||
- Blocked requests return a `403 Forbidden` response by default. | ||
- You can enable logging for blocked requests by uncommenting the `access_log` line. |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.