If you have created a Network Load Balancer (NLB) instance and added a TCP listener to a port, you can add the traffic redirection port of the instance to Web Application Firewall (WAF) to protect your web traffic. This topic describes how to add an NLB instance to WAF.
Background information
Network Load Balancer (NLB) is a next-generation Layer 4 load balancing service provided by Alibaba Cloud that is designed for the Internet of Everything (IoE) era. It provides ultra-high performance and automatic scaling. A single instance can handle up to 100 million concurrent connections, which helps you manage high-concurrency services. For more information, see What is Network Load Balancer?.
WAF supports security protection for NLB instances. After you add a port of an NLB instance to WAF, all web traffic to that port is directed to WAF for inspection through a specified gateway. WAF filters out web application attacks and forwards normal traffic back to the NLB server.
Limits
You can add Alibaba Cloud services such as Application Load Balancer (ALB), Microservices Engine (MSE), Function Compute (FC), Classic Load Balancer (CLB), Elastic Compute Service (ECS), Network Load Balancer (NLB) to Web Application Firewall (WAF) in cloud native mode. To protect web applications that are not deployed on Alibaba Cloud, add their domain names to WAF in CNAME record mode. For more information, see Add a domain name to WAF.
Limited Item Type | Description |
Supported instances | Must be both:
|
Supported regions |
|
Number of traffic redirection ports | The number is the same as the number of protected objects:
|
Port configuration |
|
Prerequisites
A WAF 3.0 instance is purchased. For more information, see Activate a pay-as-you-go WAF 3.0 instance.
You have created an NLB instance that meets the requirements and added a TCP listener to it. For more information about the requirements, see Limits. For more information about how to add a TCP listener to an NLB instance, see Add a TCP listener.
If you use a subscription instance, ensure that your instance has sufficient quota to add protected objects. Otherwise, you cannot add cloud services.
You can go to the Protected Objects page to view the remaining quota for protected objects.

Add a traffic redirection port
When you add an instance to WAF, your web service may be interrupted for several seconds. If clients can automatically reconnect, the service resumes automatically and is not affected. We recommend that you monitor your service and prepare disaster recovery mechanisms, such as reconnection and back-to-origin, as needed.
After an NLB instance is added to WAF, the traffic redirection port is automatically removed from the protection list if the protected listener port is deleted or the instance is released. If mutual authentication is enabled, the instance status in the WAF console changes to Protection Abnormal.
If any of these situations occur, you must first correct the NLB instance configuration and then add the instance to WAF again in the WAF console. Otherwise, service traffic will not be protected by WAF.
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 Onboarding.
Click the Cloud Native Mode tab. From the cloud service list on the left, select Network Load Balancer (NLB).
On the authorization page, click Authorize Now to authorize your WAF instance to access the required cloud service.
Alibaba Cloud automatically creates the AliyunServiceRoleForWAF service-linked role. To view the service-linked role, log on to the Resource Access Management (RAM) console and choose in the left-side navigation pane.
NoteIf the authorization is complete, the authorization page is not displayed. You can proceed to the next step.
View your Network Load Balancer (NLB) instances and their WAF protection status in the list on the right. If you cannot find the target instance, click Sync Assets in the upper-right corner of the page. Find the NLB instance that you want to add to WAF, click the
icon to expand its details, select the port to configure, and then click Add Now in the Actions column.
In the dialog box that appears, complete the following configurations.
Configuration Item
Related Operations
Select Protocol Type For Port
Select a Protocol Type for the port. Valid values: HTTP and HTTPS.
If you select HTTPS, you must upload a certificate.
NoteThe cloud native mode does not support SM certificates.
The total number of default and extension certificates cannot exceed 25. To upload more certificates, contact your business manager or solution architect.
Default Certificate
After you select HTTPS, you can also enable the following Advanced Settings:
If your website supports HTTP/2, you can select HTTP2 to enable protection for HTTP/2 services.
NoteThe port for the HTTP/2 protocol is the same as the port for the HTTPS protocol.
Is There A Layer 7 Proxy (such As Anti-DDoS Or CDN) In Front Of WAF?
Resource Group
Select the resource group to which the domain name belongs. 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 cloud resources by dimensions such as business department or project. For more information, see Create a resource group.
Advanced Settings
Click OK.
After the instance is added, WAF automatically creates a protected object named "Instance ID-Port-Asset Type" and associates all default mitigation templates with it. In the provisioning list, you can click the instance ID to navigate to the Protected Objects page, view the automatically created protected object, and configure protection rules for it. For more information, see Mitigation settings overview.

Related operations
View origin servers and manage traffic redirection ports
After an instance is added to WAF, you can view detailed protection information for the origin server and forcibly disable or delete traffic redirection ports for emergency disaster recovery.
On the Onboarding page, click the Cloud Native tab.
On the Network Load Balancer (NLB) tab, click the
icon for the target instance to view the ports that are protected by WAF.
View Port Details: Click Port Details to view information about the port, protocol, and the configured certificate. You can also configure the following settings: Is there a Layer 7 proxy (such as Anti-DDoS or CDN) in front of WAF?, Enable Traffic Marking (Advanced Settings), and Configure back-to-origin persistent connections (Advanced Settings).
Remove from WAF: Click Remove, and in the Remove dialog box, click OK.
ImportantWhen you remove an instance from WAF, your web services may experience transient connection interruptions that last for a few seconds. If clients can automatically reconnect, the connections are automatically restored and your services are not affected. We recommend that you monitor your services and prepare disaster recovery mechanisms, such as reconnection or back-to-origin routing, based on your service architecture.
After you remove the instance, traffic to your asset is no longer protected by WAF. To re-enable protection, you can click Add Now to add the port again. For more information, see Add a traffic redirection port.
Update the certificate bound to a traffic redirection port
If a certificate is about to expire or is changed for other reasons, such as revocation, you must update the certificate that is bound to the traffic redirection port.
When a certificate has less than 30 calendar days of validity remaining, WAF displays an
icon in the record list to indicate that the certificate is about to expire. You must update it promptly to avoid affecting normal business operations.You can set up SSL certificate message reminders to receive notifications by email, text message, and other methods before the certificate expires. For more information, see Set up message notifications for SSL certificates.
To avoid business interruptions caused by an expired certificate, enable the certificate hosting service of Alibaba Cloud Certificate Management Service (Original SSL Certificate). This service automatically requests certificates before they expire. For more information, see What is Certificate Hosting Service?.
Perform the following steps:
Renew the certificate or upload a third-party certificate to Certificate Management Service (Original SSL Certificate). For more information, see Renew an SSL certificateor Upload, sync, and share SSL certificates.
Sync the certificate to WAF.
Update the certificate in the WAF console.
On the Cloud Native tab, select the Network Load Balancer (NLB) tab. Find the target instance. In the Actions column for the target port, click the
icon, and then click Modify.In the Default Certificate section, select Select Existing Certificate and choose the new certificate.
Configure protected objects
If you have multiple domain names that resolve to the same NLB instance and you want to configure separate protection rules for each domain name after you add the instance to WAF, you must manually add the domain names as protected objects. For more information, see Manually add a protected object.