Managing traffic sources
- Setup steps
- Required paid resources
- Create a security profile
- Set up a rule for Tor, proxy, and anonymous networks
- Set up a rule for VPN traffic
- Set up a rule based on regions
- Check the order of executing the rules
- Connect a security profile to the resources
- Test the rules in logging mode
- Activate the production mode
Smart Web Security allows you to configure request processing rules according to the source of traffic. For example, you can separately process requests from the Tor network, VPNs, anonymous networks, public proxies, or from individual countries.
All this is done with the help of preset Yandex Cloud IP address lists. These lists group IP addresses and networks together based on a particular characteristic, e.g., being Tor or VPN. The service maintains and regularly updates the lists.
This guide describes how to set up common traffic filtering rules based on source.
Setup steps
- Create a security profile.
- Set up a rule for Tor, proxy, and anonymous networks.
- Set up a rule for VPN traffic.
- Set up a rule based on regions.
- Check the order of executing the rules.
- Connect a security profile to the resources.
- Test the rules in logging mode.
- Activate the production mode.
Required paid resources
- Fee for the number of requests to Smart Web Security based on plans detailed in Yandex Smart Web Security pricing policy.
- Fee for the infrastructure of the protected resource depending on its location.
This guide assumes that you already have a configured web resource in your Yandex Cloud infrastructure. If your web resource is located in a different infrastructure, connect it to a proxy server as per Setting up basic protection in Smart Web Security.
Create a security profile
This guide uses a ready-made security profile template.
-
In the management console
, select the folder containing the protected resources. -
Navigate
to Smart Web Security. -
In the left-hand panel, select
Security profiles. -
Click Create profile and select
From a preset template.A preset profile includes:
- Basic default rule enabled for all traffic with the
Allowaction type. - Smart Protection rule,
sp-rule-1, enabled for all traffic with theAPI protectionaction type.
- Basic default rule enabled for all traffic with the
-
Enter a name for the profile, e.g.,
sources-manage. -
Enable test mode for the
sp-rule-1Smart Protection rule:- For Action for the default base rule, select
Allow. - Next to
sp-rule-1, click → Edit. - Enable Only logging.
- Click Save changes.
- For Action for the default base rule, select
-
Under Fine-tuning ML models, do not withdraw your consent to the use of HTTP request info to improve your machine learning models. Otherwise, Smart Web Security will not be getting the data it needs to investigate security incidents.
-
Click Create.
Set up a rule for Tor, proxy, and anonymous networks
Such traffic is identified with the help of the is_tor, is_proxy, and is_anonymous lists.
- Open the security profile you created earlier.
- Click
Add rule. - Enter a name for the rule, e.g.,
traffic-sources-rule. - Enable Only logging.
- Set a higher priority than the Smart Protection rules, e.g.,
9100. - Specify the rule settings:
- Type:
Base. - Traffic:
On condition. - Conditions:
IP. - Conditions for IP:
IP belongs to the list.
- Type:
- For the
is_torlist, selectDeny. - Create a separate rule or add an additional condition for the
is_proxyandis_anonymouslists with theShow CAPTCHAaction. - Click Add.
This set of rules helps block traffic from Tor immediately and, separately, check requests from public proxies and anonymous networks via SmartCaptcha.
Set up a rule for VPN traffic
VPN traffic is identified with the help of the is_vpn and is_ml_vpn lists.
You can set separate processing rules for such traffic as per your security policy: allow, block, require CAPTCHA, or apply further restrictions in the ARL profile.
Warning
VPN traffic detection is based on Yandex Cloud IP addresses and does not guarantee complete accuracy. False positives and false negatives are a possibility. Your decision to block VPN traffic should align with your business scenarios, as some of your real users may be using VPN.
- In the security profile, click
Add rule. - Enter a name for the rule, e.g.,
vpn-traffic-rule. - Enable Only logging.
- Set up priority for the rule to be executed in the right order relative to other rules in the lists.
- Specify the rule settings:
- Type:
Base. - Traffic:
On condition. - Conditions:
IP. - Conditions for IP:
IP belongs to the list.
- Type:
- Select the list:
is_vpnoris_ml_vpn. - Select the VPN traffic action:
Allow: If VPN traffic is allowed.Deny: If VPN traffic has to be blocked.Show CAPTCHA: If further verification is required.
- Click Add.
To limit the request rate for VPN traffic, create an ARL profile and add to it a rule with conditions for the is_vpn and is_ml_vpn lists.
Set up a rule based on regions
- In the security profile, click
Add rule. - Enter a name for the rule, e.g.,
geo-traffic-rule. - Enable Only logging.
- Set a higher priority than the Smart Protection rules but with due consideration for existing list-based rules.
- Specify the rule settings:
- Type:
Base. - Traffic:
On condition. - Conditions:
IP. - IP conditions:
IP belongs to regionorIP does not belong to region.
- Type:
- Select the countries of interest using the two-letter code, e.g.,
RU,KZ,BY. - Select an action:
Allow: To allow traffic.Deny: To bock traffic.Show CAPTCHA: To send requests to SmartCaptcha.
- Click Add.
If your service targets only a few countries, it is best to use the IP does not belong to region condition. Then you can explicitly specify allowed regions and restrict the rest of the traffic.
Check the order of executing the rules
Security profile rules are applied on first-to-trigger basis. Therefore, specify the processing order ahead of time:
- First come the allowing rules for trusted traffic.
- Then, rules for high-risk sources.
- Then, rules based on regions.
- After that, the Smart Protection rules and other general rules.
For more on the order of executing the rules, click here.
Connect a security profile to the resources
If the load balancer is managed by an Application Load Balancer ingress controller, use the ingress resource annotation.
Tip
We recommend using the new Yandex Cloud Gwin controller instead of an ALB Ingress controller and Gateway API.
To connect a virtual host:
-
In the management console
, select the folder containing the security profile. -
Navigate
to Smart Web Security. -
In the left-hand panel, select
Security profiles. -
Select the security profile you want to connect to the virtual host Yandex Application Load Balancer.
-
Click
Connect to host. -
In the window that opens, click Add resource and select Virtual host.
-
Set the Load balancer, HTTP router, and Virtual host values one by one. You can associate the security profile with multiple virtual hosts at once.
To associate the profile with another L7 load balancer, click Add resource and select Virtual host.
-
Click Connect. If the selected hosts are already connected to another security profile, confirm the connection.
You will see the connected virtual hosts under Connected resources.
The security profile is assigned to a particular virtual host of the L7 load balancer, with all incoming host traffic analyzed. If analysis of traffic to certain host routes is not required, disable the security profile for those routes. You can do this by using the --disable-security-profile (disableSecurityProfile) parameter when adding or updating a route via the CLI, API, or Terraform.
When adding routes, consider their order: a request will follow the first route with a matching predicate, so place the most specific routes first. Otherwise, the shared route may intercept requests, and the specific rules will not apply.
To connect an API gateway:
-
In the management console
, select the folder containing the security profile. -
In the left-hand panel, select
Security profiles. -
Select the security profile you want to connect to the API gateway.
-
Click
Connect to host. -
In the window that opens, click Add resource and select API gateway.
-
Set a value in the API gateway field.
-
Click Connect.
You will see the connected API gateways under Connected resources.
To connect a domain:
-
In the management console
, select the folder containing the security profile. -
In the left-hand panel, select
Security profiles. -
Select the security profile you want to connect to a domain.
-
Click
Connect to host. -
In the window that opens, click Add resource and select Domain.
-
Set the Proxy server and Domain values one by one. You can connect the security profile to multiple domains at once.
-
Click Connect.
You will see the connected domains under Connected resources.
Test the rules in logging mode
Keep the new rules in the Only logging mode for a few days. During which period:
- Analyze which requests are covered by the rules.
- Estimate the share of legitimate traffic.
- Update your lists, regions, and actions.
Use logs and the service's monitoring capabilities for your analysis. For more information, see Configuring logging via Smart Web Security and Monitoring in Smart Web Security.
Activate the production mode
After testing, disable Only logging for the rules. Keep on monitoring and updating the rules as needed.