All Products
Search
Document Center

Server Load Balancer:Redirect requests from HTTP to HTTPS

Last Updated:Feb 28, 2023

HTTPS is a protocol used to encrypt data transmission. Classic Load Balancer (CLB) supports HTTPS, which provides end-to-end encryption for data transmission. You can enable HTTP-to-HTTPS redirection on your CLB instance. HTTP-to-HTTPS redirection is available in all regions.

In this example, HTTP-to-HTTPS redirection is enabled for CLB to redirect requests from port 80 of an HTTP listener to port 443 of an HTTPS listener.

Precautions

To configure HTTP-to-HTTPS redirection, you must first create an HTTPS listener. Then, create an HTTP listener and specify the HTTPS listener as the destination to which requests are redirected. The HTTP listener and the HTTPS listener must belong to the same CLB instance.

Prerequisites

Step 1: Create an HTTPS listener

  1. Log on to the CLB console.

  2. In the top navigation bar, select the region where the CLB instance is deployed.

  3. Use one of the following methods to open the listener configuration wizard:

    • On the Instances page, find the CLB instance that you want to manage and click Configure Listener in the Actions column.

    • On the Instances page, click the ID of the CLB instance that you want to manage. On the Listeners tab, click Add Listener.

  4. In the Protocol and Listener step, set the following parameters and click Next.

    The following section describes only the parameters relevant to this topic. The default values are used for the other parameters. For more information about the other parameters and how to create an HTTPS listener, see Create an HTTPS listener.

    • Select Listener Protocol: HTTPS.

    • Listening Port: 443.

  5. In the SSL Certificates step, select the server certificate that you uploaded. You can also click Create Server Certificate to upload a server certificate. Click Next.

    Retain the default values for other parameters.

  6. In the Backend Servers step, select backend servers. In this example, backend servers are added to the default server group.

    1. Select Default Server Group and click Add More.

    2. In the My Servers panel, select ECS01 and ECS02 and click Next.

    3. In the Ports/Weights step, click Add.

    4. Configure the ports for ECS01 and ECS02. In this example, set the ports to 80 and click Next.

  7. In the Health Check step, use the default settings and click Next.

  8. In the Confirm step, check the configurations of the listener and click Submit. After the configuration is complete, click OK in the message that appears.

Step 2: Create an HTTP listener and enable HTTP-to-HTTPS redirection for the listener

  1. On the Listener tab, click Add Listener.

  2. In the Protocol and Listener step, set the parameters based on the following information and click Next.

    Parameter

    Description

    Select Listener Protocol

    Select a listening protocol.

    HTTP is selected in this example.

    Backend Protocol

    In this example, HTTP is used, and Backend Protocol is set to HTTP.

    Listening Port

    Set the listening port that is used to receive requests and forward them to backend servers.

    In this example, 80 is used.

    Listener Name

    Specify a name for the listener.

    Advanced

    You can click Modify to configure the advanced settings.

    In this example, only the value of the Redirection parameter is modified. The default settings are used for the other parameters.

    Redirection

    Specify whether to redirect traffic from the HTTP listener to an HTTPS listener.

    In this example, Redirection is enabled and the HTTPS listener created in Step 1: Create an HTTPS listener is specified for Target Port.

  3. On the Confirm tab, click Submit. After the configuration is complete, click OK.

This way, all HTTP requests on port 80 of the HTTP listener are redirected to port 443 of the HTTPS listener and are forwarded based on the configurations of the HTTPS listener.

Why am I unable to find the Redirection parameter of an HTTP listener?

You cannot enable redirection for existing HTTP listeners. You must create a new HTTP listener before you can configure redirection.