ModSecurity
ModSecurity is an open-source Web Application Firewall (WAF) designed to protect web applications from malicious attacks. It is maintained by the open-source community and supports various programming languages and web servers. The platform Load Balancer (ALB) supports configuring ModSecurity, allowing for individual configurations at the Ingress level.
TOC
Terminology
Procedure to Operate
Configure ModSecurity by adding annotations to the corresponding resource's YAML file or by configuring CR.
Method One: Add Annotations
Add the following annotations to the metadata.annotations field of the corresponding YAML file to configure ModSecurity.
-
Ingress-Nginx Compatible Annotations
-
ALB Special Annotations
Method Two: Configure CR
-
Open the ALB, FT, or Rule configuration file that needs to be configured.
-
Add the following fields under spec.config as required.
-
Save and apply the configuration file.
Related Explanations
Override
If ModSecurity is not configured in the Rule, it will attempt to find the configuration in FT; if there is no configuration in FT, it will use the configuration from ALB.
Configuration Example
The following example deploys an ALB named waf-alb and a demo backend application named hello. Additionally, an Ingress named ing-waf-enable is deployed, which defines the /waf-enable route and configures ModSecurity rules. Any request containing the query parameter test, where the value includes the string test, will be blocked.