Emergency DDoS protection in Application Load Balancer, L7
- Conditions to implement the described solution
- Steps to set up protection
- Required paid resources
- Create a security profile
- Associate the security profile with the virtual host
- Configure an existing security profile
- Test the security profile
- Set up additional DDoS protection rules
- How to delete the resources you created
This guide will help you stop a live DDoS attack
Conditions to implement the described solution
- Your services are hosted in Yandex Cloud or connected to Application Load Balancer via Cloud Interconnect.
- You used an L7 Application Load Balancer to publish your services online.
- The DDoS attack targets the application layer (L7) by flooding it with HTTP requests (GET/POST).
Tip
Estimate your standard service load. You can do this in Application Load Balancer under Monitoring. The RPS chart displays the total number of incoming requests per second the load balancer receives. To analyze the normal load, select a period before the DDoS attack.
Steps to set up protection
To stop a DDoS attack, you need to connect Smart Web Security and set up rules to block malicious traffic.
-
Associate the security profile with a virtual host.
If you have an existing security profile associated with a host, check the profile settings.
After you stop the attack, you can set up dedicated protection for your service in Smart Web Security. If you no longer need the resources you created, delete them.
Required paid resources
The cost of infrastructure for DDoS protection includes a fee for requests processed by security profile rules (see Yandex Smart Web Security pricing).
Create a security profile
Security profiles are the main component of Smart Web Security. A profile consists of rules for handling HTTP traffic. Such rules define filtering conditions and actions to apply to the traffic flowing through a virtual host of an L7 load balancer.
To quickly deploy protection, you can use the preset template. The template contains optimal settings for basic protection of web services.
To create a security profile:
- In the management console
, select the folder the protected resources are in. - In the list of services, select Smart Web Security.
- In the left-hand panel, select Security profiles.
- Click Create profile and select From a preset template.
- Enter a name for the profile, e.g.,
anti-ddos. - In the Action for the default base rule field, select
Deny. - In the SmartCaptcha list, leave the
Defaultvalue. - Click Create.
Associate the security profile with the virtual host
If the load balancer is managed by an Application Load Balancer ingress controller, use the ingress resource annotation.
-
At the top right of the page with security profile properties, click
Connect to host. -
Select the following in the given order:
-
Virtual host. You can associate the security profile with multiple virtual hosts at once.
To connect another L7 load balancer, click Add load balancer.
-
Click Connect.
In the Connected hosts tab, you will see the connected virtual hosts.
Configure an existing security profile
If you have an existing security profile, check and adjust its parameters:
-
SmartCaptcha:
Default -
Make sure there is a rule named
sp-rule-1with the following parameters:- Type:
Smart Protection - Action:
Full protectionfor website protection with suspicious requests redirected to SmartCaptcha orAPI protectionto block suspicious requests. - Conditions:
All traffic - Priority:
999900
- Type:
-
Make sure there is a basic rule with the following parameters:
- Action:
Deny - Conditions:
All traffic - Priority:
1000000
- Action:
Test the security profile
To test your security profile, use information from monitoring charts and logs.
Monitoring
- From the list of services, select Smart Web Security.
- Navigate to Monitoring.
- Examine the data displayed on the charts:
- Denied by Security Profile RPS: Number of incoming requests per second the security profile has checked and blocked.
- Redirected to SmartCaptcha RPS: Number of incoming requests per second routed to SmartCaptcha for additional verification.
- Denied by ARL Profile RPS: Number of incoming requests per second exceeding the ARL profile limit and blocked.
For detailed description of charts, see Monitoring in Smart Web Security.
Logging
-
Make sure you have configured logging for the L7 load balancer.
-
From the list of services, select Application Load Balancer.
-
Select the load balancer with an associated security profile.
-
Navigate to Logs.
-
Select the number of messages per page and the period, e.g.,
1 hour. -
In the Query field, specify you query using the filter expression language and click Run.
Request examples:
-
Show requests which triggered a Smart Protection rule with a CAPTCHA challenge:
json_payload.smartwebsecurity.matched_rule.rule_type = SMART_PROTECTION and json_payload.smartwebsecurity.matched_rule.verdict = CAPTCHA -
Show requests blocked by the ARL profile rules:
json_payload.smartwebsecurity.advanced_rate_limiter.verdict = DENY
-
For more information about working with logs, see Configuring logging via Smart Web Security.
Set up additional DDoS protection rules
To protect your service against load bursts, set a request limit in the ARL (Advanced Rate Limiter) profile.
Set a request limit
-
From the list of services, select Smart Web Security.
-
In the left-hand panel, select
ARL profiles. -
Click Create ARL profile.
-
Enter a name for the profile, e.g.,
anti-ddos-arl. -
Click
Add rule and specify:- Name:
arl-rps. - Priority:
1000. - Traffic:
All traffic. - Request grouping:
Without grouping. - Request limit: Specify the average number of requests for your service with a small margin. All requests above the limit will be blocked.
- Name:
-
Click Save rule.
-
Click Create.
-
In the left-hand panel, select Security profiles.
-
Click
next to theanti-ddosprofile and select Edit. -
From the list of ARL profiles, select
anti-ddos-arl. -
Click Save.
Configure blocking by IP address lists
Smart Web Security has pre-configured lists of untrusted addresses, which get updated on a regular basis. You can create your own lists of trusted or untrusted addresses and add them to request filtering conditions.
- From the list of services, select Smart Web Security.
- In the left-hand panel, select Security profiles.
- Select the
anti-ddossecurity profile. - Click
Add rule. - Enter the Name, e.g.,
block-by-list. - Specify the rule settings:
- Priority: Higher than that of
sp-rule-1, e.g.,1000. - Type:
Base. - Action:
DenyorShow CAPTCHA. - Traffic:
On condition. - Conditions:
IP. - Conditions for IP:
IP belongs to the list. - Select the address lists. Requests from these addresses will be blocked.
is_ddoser: List of IP addresses used in DDoS attacks.- Click + or and select
is_tor: IP addresses of the Tor network used for traffic anonymization. - Click + or and select
is_anonimous: IP addresses of anonymous networks frequently used to hide one’s identity.
- Priority: Higher than that of
- Click Add.
Configure blocking by IP address region
Block all requests from the region the attack is coming from. If your service does not operate in certain regions, you can block traffic from those regions in advance. DDoS attacks often come from IP addresses of non-target countries.
-
Select the
anti-ddossecurity profile. -
Click
Add rule. -
Enter the Name, e.g.,
block-by-geo. -
Specify the rule settings:
-
Priority: Higher than that of
sp-rule-1but lower than that ofblock-by-list, e.g.,2000. -
Type:
Base. -
Action:
DenyorShow CAPTCHA. -
Traffic:
On condition. -
Conditions:
IP. -
Conditions for IP:
IP belongs to the region. -
Select the region the attack is coming from, e.g.,
CN,US, orIN.To add another region, click + or.
Tip
If your service operates only in certain regions, select the
IP does not belong to the regioncondition. In the list, specify the target region, e.g.,RU. Traffic from other regions will be blocked.You can check the region of an IP address at ipinfo.io
or with an ASN provider . -
-
Click Add.
Use information from monitoring charts and logs to test the rules. If necessary, adjust the request limit in the ARL profile.
How to delete the resources you created
To stop paying for the resources you created, do one of the following:
- Disassociate the security profile from the virtual host.
- Delete the security profile.