Redirect HTTP to HTTPS for Lightsail load balancers - Amazon Lightsail

Redirect HTTP to HTTPS for Lightsail load balancers

After you configure HTTPS on your Amazon Lightsail load balancer, you can configure an HTTP to HTTPS redirect so that users who browse to your website or web application using an HTTP connection are automatically redirected to the encrypted HTTPS connection. For more information about load balancers, see Load balancers.

Complete the prerequisites

Complete the following prerequisites if you haven't already:

Configure HTTPS redirection on your load balancer using the Lightsail console

Complete the following procedure to configure HTTPS redirection on your load balancer using the Lightsail console.

  1. Sign in to the Lightsail console.

  2. On the Lightsail home page, choose the Networking tab.

  3. Choose the name of the load balancer for which you want to configure HTTPS redirection.

  4. Choose the Inbound traffic tab.

  5. In the Protocols section of the page, you can perform one of the following actions:

    The toggle to activate or deactivate HTTP to HTTPS redirection on a load balancer
    • Toggle the direction option to active to turn on HTTP to HTTPS redirection.

    • Toggle the direction option to inactive to turn off HTTP to HTTPS redirection.

    Your change takes a few moments to become effective.

Configure HTTP to HTTPS redirect for a load balancer with the AWS CLI

Complete the following procedure to configure HTTPS redirection on your load balancer using the AWS Command Line Interface (AWS CLI). You do this by using the update-load-balancer-attribute command. For more information, see update-load-balancer-attribute in the AWS CLI Command Reference.

Note

You must install the AWS CLI and configure it for Lightsail before continuing with this procedure. For more information, see Configure the AWS CLI to work with Lightsail.

  1. Open a Command Prompt or Terminal window.

  2. Enter the following command to configure HTTPS redirection on your load balancer.

    aws lightsail update-load-balancer-attribute --load-balancer-name LoadBalancerName --attribute-name HttpsRedirectionEnabled --attribute-value AttributeValue

    In the command, replace the following example text with your own:

    • LoadBalancerName with the name of the load balancer for which you want to activate or deactivate HTTP to HTTPS redirection.

    • AttributeValue with true to activate redirection, or false to deactivate redirection.

      Note

      The HttpsRedirectionEnabled attribute in the command specifies that you wish to edit whether HTTPS redirection is enabled or disabled for the specified load balancer.

    Examples:

    • To activate HTTP to HTTPS redirection on your load balancer:

      aws lightsail update-load-balancer-attribute --load-balancer-name MyLoadBalancer --attribute-name HttpsRedirectionEnabled --attribute-value true
    • To deactivate HTTP to HTTPS redirection on your load balancer:

      aws lightsail update-load-balancer-attribute --load-balancer-name MyLoadBalancer --attribute-name HttpsRedirectionEnabled --attribute-value false

    Your change takes a few moments to become effective.