This topic describes how to use an Anti-DDoS Origin paid edition and Web Application Firewall (WAF) to provide protection. This solution protects your website against Layer 4 distributed denial of service (DDoS) attacks, Layer 7 web attacks, and HTTP flood attacks.
Prerequisites
An Elastic Compute Service (ECS) instance is created and has web applications deployed. The ECS instance has a public IP address, and your website has a domain name.
NoteIf your website provides services in the Chinese mainland, you must complete Internet Content Provider (ICP) filing for the domain name of your website. Otherwise, you cannot add the domain name to WAF instances in the Chinese mainland to protect your website.
An Anti-DDoS Origin instance of a paid edition is purchased. For more information, see Purchase an Anti-DDoS Origin instance of a paid edition.
NoteWhen you purchase an Anti-DDoS Origin instance of a paid edition, you must select a region. Make sure that the Anti-DDoS Origin instance of a paid edition and the ECS instance reside in the same region.
A WAF 3.0 instance is purchased. For more information, see Purchase a subscription WAF 3.0 instance.
Background information
You can use an Anti-DDoS Origin paid edition to mitigate DDoS attacks for your website. If your website encounters web attacks and HTTP flood attacks, we recommend that you use WAF to protect your website. For more information about WAF, see What is WAF?
If you use an Anti-DDoS Origin paid edition and WAF to protect your website, you must add your website to WAF and then add the IP address of the WAF instance to the Anti-DDoS Origin paid edition for protection. In this case, all service traffic is first scrubbed by WAF, and only normal traffic is forwarded to the origin server. Attack traffic, such as DDoS attacks, web attacks, and HTTP flood attacks, is blocked.
Procedure
Log on to the WAF 3.0 console. In the top navigation bar, select the resource group and region of the WAF instance. You can select Chinese Mainland or Outside Chinese Mainland.
In the left-side navigation pane, click Website Configuration.
On the CNAME Record tab, click Add.
In the Configure Listener step, configure the parameters and click Next.
Parameter
Description
Domain Name
Enter the domain name that you want to protect. You can enter an exact-match domain name, such as
www.aliyundoc.com, or a wildcard domain name, such as*.aliyundoc.com. You can enter only one domain name.The first time you add a domain name to WAF, you must verify your ownership of the domain name. You can add the domain name to WAF only after you successfully verify your ownership of the domain name. For more information, see Verify the ownership of a domain name.
NoteYou can use a wildcard domain name to match all subdomains at the same level but not across different levels. For example,
*.aliyundoc.comcan matchwww.aliyundoc.comandexample.aliyundoc.com, but not*.aliyundoc.comcannot matchwww.example.aliyundoc.com.A second-level wildcard domain name can cover its second-level parent domain name. For example,
*.aliyundoc.comcan coveraliyundoc.com.A third-level wildcard domain name cannot cover its third-level parent domain name. For example,
*.example.aliyundoc.comcannot coverexample.aliyundoc.com.If you add an exact-match domain name and a wildcard domain name that covers the exact-match domain name, the protection rules that are configured for the exact-match domain name take precedence.
Protocol Type
Select the protocol type and ports that are used by your website service. Press the Enter key each time you enter a port number.
NoteThe port number that you enter must be within the range of ports that are supported by WAF. You can click View Port Range to view the HTTP and HTTPS ports that are supported by WAF. For more information, see View supported ports.
If you select HTTPS, configure the HTTPSUpload Type parameter to specify the method that you want to use to upload an SSL certificate. Then, upload the SSL certificate bound to the domain name to WAF. This way, WAF can monitor the HTTPS traffic of the website.
In the HTTPS Certificate Upload Mode section, specify the method that you want to use to upload an SSL certificate.
NoteWAF (version_share_vm) does not support HTTPS.
If you select HTTPS and upload a certificate, you can perform the following operations based on your business requirements:
If your website supports HTTP/2, select HTTP2 to protect HTTP/2 requests.
NoteThe HTTP/2 ports are the same as the HTTPS ports.
Advanced Settings
Whether Layer 7 Proxy, Such As Anti-DDoS Pro, Anti-DDoS Premium, Or Alibaba Cloud CDN, Is Deployed In Front Of WAF
Specify whether a Layer 7 proxy, such as Anti-DDoS Pro or Alibaba Cloud CDN, is deployed in front of WAF. Valid values:
More Settings
Resource Group
Select the resource group to which you want to add the domain name from the drop-down list. If you do not select a resource group, the domain name is added to the Default Resource Group.
NoteYou can use Resource Management to create resource groups and manage resources within your Alibaba Cloud account by department or project. For more information, see Create a resource group.
In the In the Configure Forwarding Rule step, configure the parameters and click Submit.
Parameter
Description
Load Balancing Algorithm
If you specify multiple origin server addresses, select the Load Balancing Algorithm that you want WAF to use to forward back-to-origin requests to the origin servers. Valid values:
Origin Server Address
Specify the public IP address or domain name of the origin server. The IP address or domain name is used to receive the back-to-origin requests that are forwarded by WAF. Valid values:
- Important
If the public IP address of the origin server changes, you need to manually
add the new back-to-origin IP address.
Standby Link Back-to-origin
After you enable the standby link back-to-origin feature, if all IP addresses in the primary link are unreachable, the system automatically switches to the IP addresses in the standby link. The switchover is triggered when the traffic is at least 100 QPS and takes effect within 30 seconds. After the primary link is restored, the system automatically switches back to the primary link. Configuration parameters:
- Important
If the public IP address of the origin server changes, you need to manually
add the new back-to-origin IP address.
Advanced HTTPS Settings
Other Advanced Settings
In the Add Completed step, obtain the CNAME assigned to the domain name. Modify the DNS record to point the domain name to the CNAME that is provided by WAF. For more information, see Modify the DNS record of a domain name.
ImportantBefore you modify the DNS record, make sure that the following conditions are met:
The forwarding configurations for your website are correct and have taken effect. If you modify the DNS record before the forwarding configurations for your website take effect, service interruptions may occur. For more information, see Verify domain name settings.
The back-to-origin CIDR blocks of WAF are added to the IP address whitelist of the third-party firewall used by the origin server on which the domain name is hosted. This prevents normal requests that are forwarded by WAF from being blocked. You can click Back-to-origin CIDR Blocks to view and copy the back-to-origin CIDR blocks of WAF. For more information, see Allow access from back-to-origin CIDR blocks of WAF.

After you complete the preceding configurations, you can perform the following operations to check whether the domain name is added to WAF:
Enter the domain name in your browser. If you can access the website, the domain name is added to WAF.
Enter the domain name and malicious code such as
<Protected domain name>/alert(xss), wherealert(xss)is cross-site scripting (XSS) attack code used for testing. If a 405 error page appears, the attack is blocked and the domain name is protected by WAF.
ImportantIf you add a domain name to WAF in CNAME record mode, WAF checks whether ICP filing is complete for the domain name and whether the ICP filing information is valid on a regular basis. If the ICP filing information of the domain name becomes invalid, WAF stops forwarding requests for the domain name, as shown in the following figure.

If the ICP filing information of a domain name that is added to WAF becomes invalid, you must re-apply for an ICP filing for the domain name. After the application is successful, you can go to the CNAME Record tab of the Website Configuration page and click Add Again in the Actions column to re-add the domain name to WAF.
Run the ping command
ping CNAME of WAFon your computer to obtain the IP address of the WAF instance.Add the IP address of the WAF instance to your Anti-DDoS Origin instance of a paid edition for protection. For more information, see Add an object for protection.
After you add the IP address of the WAF instance, the Anti-DDoS Origin instance of a paid edition provides best-effort protection. The Anti-DDoS Origin instance of a paid edition automatically scrubs service traffic to mitigate DDoS attacks.