Service Mesh (ASM) allows you to configure a blacklist or whitelist for an ingress gateway to reject or allow requests from a specific IP address, HTTP domain, or port. This topic describes how to configure a blacklist or whitelist for an ingress gateway to reject or allow requests from a specific IP address. This ensures the security of applications in the mesh.
Prerequisites
An application is deployed in the Container Service for Kubernetes (ACK) cluster that is added to your ASM instance. For more information, see Deploy an application in an ASM instance.
Matching rule description
A request for which a blacklist or whitelist takes effect must match one of the rules and match all the criteria in the rule.
After you turn off Enable Black/White List on the Black/White List Matching Rules page, the corresponding authorization rules are automatically cleared.
HTTP domain names, or host names, support exact match, prefix match, and suffix match. Examples:
Exact match: aliyun.com
Prefix match: aliyun*
Suffix match: *aliyun.com
Preparations
Configure a blacklist for the ingress gateway to reject requests from the source IP address of the client
- Log on to the ASM console. In the left-side navigation pane, choose .
- On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose .
On the Ingress Gateway page, click the name of the ingress gateway. In the left-side navigation pane on the Gateway overview page, choose .
In the Black/White List Matching Rules step of the configuration wizard, turn on Enable Black/ White List, select Blacklist for Match Mode, turn on IPBlock, enter the source IP address of the client, and then click submit.
For more information about how to obtain the source IP address of the client, see Preparations.
NoteIf you want to configure multiple matching rules, click Add Request Matching Rule. Multiple matching rules allow you to block or allow requests from multiple sources.
If the Gateway Black/White List created successfully message appears, it indicates that the blacklist is created and takes effect. You can click View YAML next to AuthorizationPolicy to view the semantic information of the blacklist.
Open a browser and enter http://{IP address of the ingress gateway}/productpage in the address bar to access the productpage service.
If the following message appears, it indicates that the blacklist takes effect.
Configure a whitelist for the ingress gateway to allow only requests from the source IP address of the client
The method of configuring a whitelist is similar to that of configuring a blacklist, except that match modes are different.
On the Ingress Gateway page, click the name of the ingress gateway. In the left-side navigation pane on the Gateway overview page, choose .
In the Black/White List Matching Rules step of the configuration wizard, select Whitelist for Match Mode and click submit.
Access the productpage service.
Enter http://{IP address of the ingress gateway}/productpage in the address box of your browser.
You can access the productpage service.
Enter http://{IP address of another ingress gateway}/productpage in the address box of your browser.
If the following message appears, it indicates that the whitelist takes effect and blocks the request from a client IP address that is not in the whitelist.