Integrate with Coraza
With rapid development of technology, it has become increasingly crucial to secure APIs. APISIX supports the integration with Coraza by using coraza-proxy-wasm to provide reliable security protection and ensure the integrity and reliability of API services.
Coraza is an open-source, enterprise-grade, high-performance Web Application Firewall (WAF). It is designed to safeguard web applications against various cyberattacks by filtering and monitoring HTTP/HTTPS communications between web applications and the internet. Integrating with Coraza, APISIX significantly enhances APISIX's ability to protect upstream services.

This guide will show you how to enable coraza-proxy-wasm to integrate APISIX with Coraza WAF to protect upstream services.
Prerequisite(s)
- Install Docker.
- Install cURL to send requests to the services for validation.
- Install ZIP to unzip the
coraza-proxy-wasmbinary from the release page. - Follow the Getting Started tutorial to start a new APISIX instance in Docker.
Download coraza-proxy-wasm
Download coraza-proxy-wasm from the release page and unzip it:
wget https://github.com/corazawaf/coraza-proxy-wasm/releases/download/0.4.0/coraza-proxy-wasm-0.4.0.zip
unzip coraza-proxy-wasm-0.4.0.zip
Copy coraza-proxy-wasm.wasm into the /usr/local/bin directory:
docker cp /path/to/coraza-proxy-wasm.wasm apisix-quickstart:/usr/local/bin/
Load coraza-proxy-wasm in APISIX
Update the config.yaml configuration file by adding coraza-proxy-wasm configurations:
docker exec apisix-quickstart /bin/bash -c "echo '
wasm:
plugins:
- name: coraza-filter
priority: 7999
file: /usr/local/bin/coraza-proxy-wasm.wasm
' >> /usr/local/apisix/conf/config.yaml"
❶ name: the name of the APISIX plugin corresponding to coraza-proxy-wasm.
❷ priority: the execution priority of the plugin.
❸ file: the absolute path to coraza-proxy-wasm.
Reload APISIX for configuration changes to take effect:
docker exec apisix-quickstart apisix reload
Configure Specific Security Rules
Create a route and enable coraza-filter:
- Admin API
- ADC
curl -i "http://127.0.0.1:9180/apisix/admin/routes/" -X PUT -d '
{
"id": "getting-started-waf",
"uri": "/anything/*",
"plugins": {
"coraza-filter": {
"conf": {
"directives_map": {
"default": [
"SecDebugLogLevel 9",
"SecRuleEngine On",
"SecRule REQUEST_URI \"@beginsWith /anything/archive\" \"id:101,phase:1,t:lowercase,deny\""
]
},
"default_directives": "default"
}
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'
❶ SecDebugLogLevel: configure the debug log level. For details, see SecDebugLogLevel.
❷ SecRuleEngine: configure the rules engine. For details, see SecRuleEngine.
❸ SecRule: check the URI value of your HTTP request to see if the URI value begins with /anything/archive. If matched, the request will be rejected. For details, see SecRule.
services:
- name: httpbin Service
routes:
- uris:
- /anything/*
name: getting-started-waf
plugins:
coraza-filter:
conf:
directives_map:
default:
- SecDebugLogLevel 9
- SecRuleEngine On
- SecRule REQUEST_URI "@beginsWith /anything/archive" "id:101,phase:1,t:lowercase,deny"
default_directives: default
upstream:
type: roundrobin
nodes:
- host: httpbin.org
port: 80
weight: 1