All Products
Search
Document Center

Web Application Firewall:Protect an ECS instance from HTTP flood attacks

Last Updated:Mar 31, 2026

Web Application Firewall (WAF) filters malicious traffic and HTTP flood attacks before they reach your ECS instance. This guide walks you through activating WAF, onboarding your ECS instance, and configuring HTTP flood protection — from zero to a working defense in four steps.

Prerequisites

Before you begin, make sure that:

  • Your ECS instance hosts a web service accessible over a public IP address

  • Your ECS instance is in one of the following supported regions:

    • China regions: China (Chengdu), China (Beijing), China (Zhangjiakou), China (Hangzhou), China (Shanghai), China (Shenzhen), China (Qingdao), China (Hong Kong)

    • Global regions: Malaysia (Kuala Lumpur), Indonesia (Jakarta), or Singapore

If your ECS instance is not in a supported region, use CNAME access instead.

Step 1: Activate a pay-as-you-go WAF instance

Warning

Pay-as-you-go WAF starts billing as soon as you activate it, even before you add any resources. If you only need WAF temporarily, release the instance when you are done. See Release resources to stop billing.

  1. Go to the Web Application Firewall 3.0 (Pay-As-You-Go) purchase page.

  2. Set Product Type to Web Application Firewall 3.0 and Billing Method to Pay-as-you-go, then configure the following settings.

    ParameterDescription
    RegionThe region of the WAF instance. Set it to the same region as your ECS instance. Options: Chinese Mainland or Outside Chinese Mainland.
    VersionDefaults to Pay-as-you-go 3.0. No configuration needed.
    Traffic billing protection thresholdKeep the default value. You can change it later.
    Service-linked roleWAF needs access to your cloud resources for traffic control and monitoring. Click Create Service-Linked Role. The system automatically creates the AliyunServiceRoleForWaf role. Do not modify this role manually.
  3. Click Buy Now and complete the payment.

Step 2: Onboard the ECS instance to WAF

  1. Log in to the Web Application Firewall 3.0 console. In the top menu bar, select a resource group and a region (Chinese Mainland or Outside Chinese Mainland). In the left navigation pane, click Onboarding, select the Cloud Native tab, then select Elastic Compute Service (ECS) from the cloud product type list.

  2. Find your ECS instance and click Add Now in the Actions column. If the instance is not listed, click Synchronize Assets in the upper-right corner.

    image

  3. Configure your website protocol and port:

    1. In the Select instances & ports to protect section, click Add Port in the Actions column.

    2. In the Add Port dialog box, configure the port and protocol based on your website type.

      Website type

      Protocol

      Port

      Additional configuration

      HTTP (http://yourdomain.com)

      HTTP

      80

      None

      HTTPS (https://yourdomain.com)

      HTTPS

      443

      Upload SSL certificate or select existing

      Custom port (http://yourdomain.com:8080)

      HTTP/HTTPS

      Custom port

      Match your actual configuration

    For HTTPS, configure the following additional settings:

    Upload SSL certificate or select existing

    1. Enter the port number in the Port field.

    2. In Protocol Type, select HTTPS.

    3. Keep the default settings for HTTP/2, TLS Version, Cipher Suite, and Additional Certificate.

    4. In the Default Certificate section, choose how to provide your certificate:

      Manual upload

      — for certificates not managed in Alibaba Cloud Certificate Management Service (Original SSL Certificate).

      • Certificate Name: Enter a unique name. It cannot match an existing certificate name.

      • Certificate File: Paste the certificate content from a text editor. Accepted formats: PEM, CER, or CRT.

        • Example: -----BEGIN CERTIFICATE-----......-----END CERTIFICATE-----

        • If your certificate is in PFX or P7B format, use the certificate tool to convert it to PEM first.

        • If the certificate includes an intermediate certificate, paste the server certificate first, then the intermediate certificate.

      • Private Key: Paste the private key content. The private key must be in PEM format.

        • Example: -----BEGIN RSA PRIVATE KEY-----......-----END RSA PRIVATE KEY-----

      Select existing certificate

      — for certificates already issued or uploaded to Alibaba Cloud Certificate Management Service (Original SSL Certificate). Select the certificate from the dropdown list.

    If the console displays "Failed to verify the integrity of the certificate chain. If you use this certificate, service access may be affected.", the certificate chain is incomplete. Verify the certificate content, then re-upload it in the Certificate Management Service console. See Upload, synchronize, and share SSL certificates.
  4. Keep the default values for the other settings and click OK. Once onboarding is complete, the ECS instance protection status changes to Full Protection. WAF automatically creates a protected object named in the format instance ID-port-asset type. By default, standard protection rules including Web Core Protection are enabled. Manage protected objects under Protection Configuration > Protected Objects.

  5. Verify that basic protection is active: append an attack string to your URL, such as http://yourdomain/alert(xss). If a WAF 405 block page appears, protection is working.

Step 3: Configure HTTP flood protection

HTTP flood attacks overwhelm servers with a high volume of requests. Configure a protection template to defend against them.

  1. In the left navigation pane, choose Protection Configuration > Core Web Protection.

  2. In the HTTP Flood Protection section at the bottom of the page, click Create Template.

    image

  3. In the Create Template panel, configure the following settings.

    Warning

    Strict Mode applies only to web (including H5) services. Do not apply it to API endpoints or native applications — it will cause excessive false blocking.

    ParameterDescription
    Template NameEnter a descriptive name, such as ECS-HTTP-Flood-Protection.
    Save as Default TemplateKeep it off.
    Defense ModeSee the mode comparison below.
    ActionSelect JavaScript Validation.
    Apply ToIn the Available Objects section, select the protected object that corresponds to your ECS instance. Click the image icon to move it to the Selected section.

    Choose a defense mode:

    ModeHow it worksWhen to use
    Normal ModeBlocks requests with significant abnormal characteristics. Low false positive rate.Start here for most cases — suitable for daily operations and stable traffic.
    Strict ModeUses high-intensity detection. More effective against floods, but has a higher false positive risk.Switch to this only when Normal Mode is insufficient and you observe response delays or abnormal CPU/memory load.
  4. Click OK.

    image

Step 4: Monitor attack traffic

After completing the configuration, go to the Overview page from the left navigation pane. The Protection Overview and Top 10 Attacks sections provide a real-time view of blocked attacks and traffic patterns.

image

Release resources to stop billing

If you no longer need WAF after completing this guide, follow these steps to stop billing.

Warning

Pay-as-you-go WAF charges for the instance itself plus request processing. Fees are generated as soon as you activate WAF, even if no resources have been added. Disable the instance as soon as possible to prevent further charges. If you configured CNAME access in addition to the cloud native mode described in this guide, switch the DNS records for affected domain names back to your origin server before terminating the WAF instance.

  1. In the left navigation pane, go to Overview. In the top menu bar, select the resource group and region (Chinese Mainland or Outside Chinese Mainland) of the WAF instance.

  2. If the following page appears, click Go to Console in the upper-right corner. If this page is not shown, skip this step.

    image

  3. On the right side of the page, click Terminate WAF Service. In the dialog box, select the relevant checkboxes and click OK.

    image

What's next

Add more protection modules:

  • Custom Rules — configure frequency control rules or match conditions to block specific attack patterns

  • Whitelist — allow requests from trusted IP addresses

  • IP Blacklist — block known malicious IP addresses

  • Geo-blocking — block traffic from specific geographic regions with a single click

Explore other onboarding methods:

Manage costs: