All Products
Search
Document Center

Serverless App Engine:Configure gateway routing for an application by using an ALB instance

Last Updated:Dec 14, 2023

After you host an application to Serverless App Engine (SAE), you can configure gateway routing for the application to distribute your requests to other services or applications. This topic describes how to configure gateway routing for an application by using an Application Load Balancer (ALB) instance.

Prerequisites

  • An application is hosted to SAE. For more information, see Application hosting overview.

  • An ALB instance is created. For more information, see Create an ALB instance.

  • You are familiar with the related limits. For more information, see Limits.

  • The application for which you want to configure gateway routing and the application that receives requests at the backend reside in the same namespace.

Background information

Server Load Balancer (SLB) is a service that distributes network traffic across groups of backend servers to increase the throughput of your applications. You can use SLB to prevent service disruptions that are caused by single points of failure (SPOFs) and improve the availability of applications. For more information, see SLB overview.

For information about how to configure gateway routing for your application by using a Classic Load Balancer (CLB) instance, see Configure gateway routing for an application by using a CLB instance.

Scenarios

The gateway routing feature is suitable for the following scenarios:

  • A single application or multiple applications need to forward traffic by using the same domain name in different paths.

  • A single application or multiple applications need to forward traffic to different domain names that are resolved to the same IP address.

After you configure gateway routing, you can use a URL in the <Domain name>:<Port number>/Path format to access the related backend services or applications.

Create a gateway route

  1. Log on to the SAE console.

  2. In the left-side navigation pane, click Applications. In the top navigation bar, select a region. Then, click the name of an application.

  3. In the Gateway Routing Settings section of the Basic Information page, click Add Forwarding Policy. On the Gateway Routing page, click Create.

  4. In the Create Routing Rule panel, configure the parameters.

    1. In the Configure Gateway Ingress step, configure the parameters and click Next. The following table describes the parameters.

      Parameter

      Description

      Name

      The name of the routing rule.

      Gateway Type

      The network type of the requests that you want to forward.

      • Internet: You are charged for the actual amount of traffic that is forwarded by using Internet gateways. The charges are included into your SAE bills.

      • Private: You are not charged for the traffic that is forwarded by using private gateways. Traffic can be forwarded only in the current virtual private cloud (VPC).

      SLB Instance Type

      Select ALB and select an ALB instance from the ALB Instance drop-down list.

      The number of ALB instances that are displayed is the same as the number of ALB instances in the SLB console. For information about the limits on SLB, see SLB usage notes.

      Frontend Protocol Type

      The protocol that is used to forward requests.

      • HTTP: HTTP is suitable for applications that must identify data from different sources, such as web applications and mobile games.

      • HTTPS: HTTPS is suitable for applications that require encrypted data transmission.

      SSL Certificate

      This parameter is required only if you set the Protocol Type parameter to HTTPS.

      You can select one or more certificates. If you select multiple certificates, the first certificate is used as the default certificate, and the subsequent certificates are used as additional certificates. If your account does not have SSL certificates, log on to the Certificate Management Service console to create SSL certificates.

      Port

      The listening port that is used to receive requests and forward the requests to backend services or applications. Valid values: 1 to 65535. Example: 80.

    2. In the Configure Forwarding Policy step, configure the parameters and click OK. The following table describes the parameters.

      Parameter

      Description

      Custom Forwarding Policy

      • Domain Name: the domain name from which requests are forwarded.

      • Path: the path from which requests are forwarded. For example, if a path is example.com/product/sae, set the request forwarding path to /product/sae.

      • Backend Protocol: the protocol type.

        • HTTP: HTTP is suitable for applications that need to identify the transmitted data. This is the default value.

        • HTTPS: HTTPS is suitable for applications that require encrypted data transmission.

        • GRPC: GRPC is suitable for load balancing scenarios in which you want to deploy services in multi-language frameworks, such as the .NET framework.

        Note

        This parameter is required only if you set the SLB Instance Type parameter to ALB and set the Frontend Protocol Type parameter to HTTPS in the Configure Gateway Ingress step.

      • Backend Application: the application that receives requests. The backend application must reside in the same namespace as the application from which requests are forwarded.

      • Container Port: the port of the container that is used to access the backend application. Example: 8080.

      Default Forwarding Policy

      • Backend Protocol: the protocol type.

        • HTTP: HTTP is suitable for applications that need to identify the transmitted data. This is the default value.

        • HTTPS: HTTPS is suitable for applications that require encrypted data transmission.

        • GRPC: GRPC is suitable for load balancing scenarios in which you want to deploy services in multi-language frameworks, such as the .NET framework.

        Note

        This parameter is required only if you set the SLB Instance Type parameter to ALB and set the Frontend Protocol Type parameter to HTTPS in the Configure Gateway Ingress step.

      • Backend Application: the backend application that receives requests.

      • Container Port: the port of the container that is used to access the backend application. Example: 8080.

      Note
      • The ports to which an SLB instance listens must be unique.

      • You cannot specify the same port for an ALB instance in different gateway routing rules.

      • You must specify a domain name in the example.com format. You must configure the Path and Domain Name parameters.

      • You can use wildcard characters to match paths. For example, if a path is /admin/, you can set the forwarding path to /admin/*.

      • If you do not configure a custom forwarding policy, SAE uses the default forwarding policy. If you do not configure a default forwarding policy, an access error occurs.

  5. Verify the result.

    • On the Event Information page of the namespace, check whether the routing rule is configured.

    • Log on to the SLB console. On the ALB Instances page, check whether the listener is configured.sc_alb_listener.png

    • Use a URL in the <Domain name>:<Port number>/Path format to access the related backend services or applications.

Manage a gateway route

After you create a routing rule, you can view the forwarding policy, modify the gateway route, and view the related events on the Gateway Routing page.