Automate the scraping of OWASP Core Rule Set (CRS) patterns and convert them into Apache, Nginx, Traefik, and HAProxy WAF configurations.
Additionally, Bad Bot/User-Agent detection is integrated to block malicious web crawlers and scrapers.
π Protect your servers against SQL Injection (SQLi), XSS, RCE, LFI, and malicious bots β with automated daily updates.
- π‘οΈ OWASP CRS Protection β Leverages OWASP Core Rule Set for web application firewall (WAF) defense.
- π€ Bad Bot Blocking β Blocks known malicious bots using public bot lists.
- βοΈ Multi-Web Server Support β Generates WAF configs for Apache, Nginx, Traefik, and HAProxy.
- π Automatic Updates β GitHub Actions fetch new rules daily and push updated configs.
- π¦ Pre-Generated Configurations β Download ready-to-use WAF configurations from GitHub Releases.
- 𧩠Scalable and Modular β Easily extendable to support other web servers or load balancers.
- π΅ Nginx
- π Apache (ModSecurity)
- π£ Traefik
- π΄ HAProxy
Note
If you are using Caddy, check the caddy-waf project.
patterns/
βββ waf_patterns/ # π§ Generated WAF config files
β βββ nginx/ # Nginx WAF configs
β βββ apache/ # Apache WAF configs (ModSecurity)
β βββ traefik/ # Traefik WAF configs
β βββ haproxy/ # HAProxy WAF configs
βββ import_apache_waf.py
βββ import_haproxy_waf.py
βββ import_nginx_waf.py
βββ import_traefik_waf.py
βββ owasp.py # π΅οΈ OWASP scraper (fetch CRS rules)
βββ owasp2nginx.py # π Convert OWASP JSON to Nginx WAF configs
βββ owasp2apache.py # π Convert OWASP JSON to Apache ModSecurity configs
βββ owasp2haproxy.py # π Convert OWASP JSON to HAProxy WAF configs
βββ badbots.py # π€ Generate WAF configs to block bad bots
βββ requirements.txt # π Required dependencies
βββ .github/workflows/ # π€ GitHub Actions for automation
βββ update_patterns.yml
owasp.py
scrapes the latest OWASP CRS patterns from GitHub.- Extracts SQLi, XSS, RCE, LFI patterns from OWASP CRS
.conf
files.
owasp2nginx.py
β Generates Nginx WAF configurations.owasp2apache.py
β Outputs Apache ModSecurity rules.owasp2traefik.py
β Creates Traefik WAF rules.owasp2haproxy.py
β Builds HAProxy ACL files.
badbots.py
fetches public bot lists and generates bot-blocking configs.- Supports fallback lists to ensure reliable detection.
You can download the latest pre-generated WAF configurations directly from the GitHub Releases page.
- Go to the Releases section.
- Download the zip file for your web server (e.g.,
nginx_waf.zip
,apache_waf.zip
). - Extract the files and follow the integration instructions below.
If you prefer to generate the configurations yourself:
1. Clone the Repository:
git clone https://github.com/fabriziosalmi/patterns.git
cd patterns
2. Install Dependencies:
pip install -r requirements.txt
3. Run Manually (Optional):
python owasp.py
python owasp2nginx.py
python owasp2apache.py
python owasp2haproxy.py
python owasp2traefik.py
python badbots.py
- Download the
nginx_waf.zip
file from the Releases page. - Extract the files to your Nginx configuration directory.
- Include the generated
.conf
files in your Nginx configuration:include /path/to/waf_patterns/nginx/*.conf;
- Download the
apache_waf.zip
file from the Releases page. - Extract the files to your Apache configuration directory.
- Include the generated
.conf
files in your Apache configuration:Include /path/to/waf_patterns/apache/*.conf
- Download the
traefik_waf.zip
file from the Releases page. - Extract the files and use the
middleware.toml
file in your Traefik configuration.
- Download the
haproxy_waf.zip
file from the Releases page. - Extract the files and include the
waf.acl
file in your HAProxy configuration.
map $http_user_agent $bad_bot {
"~*AhrefsBot" 1;
"~*SemrushBot" 1;
"~*MJ12bot" 1;
default 0;
}
if ($bad_bot) {
return 403;
}
- π Daily Updates β GitHub Actions fetch the latest OWASP CRS rules every day.
- π Auto Deployment β Pushes new
.conf
files directly towaf_patterns/
. - π¦ Release Automation β Automatically creates a new release with pre-generated configurations.
- π― Manual Trigger β Updates can also be triggered manually.
- Fork the repository.
- Create a feature branch (
feature/new-patterns
). - Commit and push changes.
- Open a Pull Request.
This project is licensed under the MIT License.
See the LICENSE file for details.
- Issues? Open a ticket in the Issues Tab.