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 a Classic Load Balancer (CLB) instance.

Prerequisites

  • An application is hosted to SAE. For more information, see Deploy a demo application on SAE.
  • A CLB instance is created. For more information, see Create and manage a CLB 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 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 application by using an Application Load Balancer (ALB) instance, see Configure gateway routing for an application by using an ALB 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 and 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.
    You can also click Gateway Routing in the left-side navigation pane of the details page of a namespace to open the Gateway Routing page.
  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.
      ParameterDescription
      NameThe name of the routing rule.
      Gateway TypeThe 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 TypeSelect CLB and select a CLB instance from the CLB Instance drop-down list.

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

      Protocol TypeThe 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 CertificateThis parameter is required only if you set the Protocol Type parameter to HTTPS.

      If your account does not have SSL certificates, log on to the CLB console to create SSL certificates.

      PortThe 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.
      ParameterDescription
      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 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 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 a CLB 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.
    • 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 may occur.
  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 CLB Instances page, check whether the listener is configured.
    • 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.