All Products
Search
Document Center

Server Load Balancer:Redirect requests from HTTP to HTTPS

Last Updated:Nov 10, 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 in which 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 & Listener step, configure the following parameters and click Next.

    The following list describes only the parameters relevant to this topic. For other parameters, use the default values. For more information about the other parameters, see Add an HTTPS listener.

    • Listener Protocol: In this example, HTTPS is selected.

    • Listener Port: In this example, 443 is entered.

  5. In the Certificate Management Service step, select the server certificate that you have uploaded from the Server Certificate drop-down list. If no certificate is available, click Create Server Certificate to upload a server certificate. Use the default values for other parameters. Then, click Next.

  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 Servers panel, select ECS1 and ECS2, and click Next.

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

    4. Set the ports for ECS01 and ECS02. In this example, 80 is entered. Then, 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 of the instance details page, click Add Listener.

  2. In the Protocol & Listener step, configure the parameters and click Next. The following table describes the parameters.

    Parameter

    Description

    Listener Protocol

    The listener protocol.

    In this example, HTTP is selected.

    Listener Port

    The listener port that is used to receive requests and forward them to backend servers.

    In this example, 80 is used.

    Listener Name

    The custom name of the listener.

    Advanced Settings

    You can click Modify next to Advanced Settings to configure the advanced settings.

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

    Redirection by Listener

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

    In this example, Redirection by Listener is enabled and the HTTPS listener created in Step 1: Create an HTTPS listener is selected from the Listener drop-down list.

  3. In the Confirm step, 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 by Listener parameter of an HTTP listener?

You cannot enable Redirection by Listener for existing HTTP listeners. You must create a new HTTP listener before you can configure the Redirection by Listener parameter.