---
title: "Configure HTTP → HTTPS redirect"
sidebar_label: "Configure HTTP → HTTPS redirect"
sidebar_position: 1
description: "How to configure a rule to redirect HTTP requests to the HTTPS version of a site"
---

import Formbricks from '@theme/MDXComponents/Formbricks'

import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'
import {TabItemLabel} from '@selectel/docux/components'

# Configure HTTP → HTTPS redirect

<Tabs queryString="redirect-http-https">
  <TabItem value="panel" default>
    <TabItemLabel>
      Control panel
    </TabItemLabel>

    1. Ensure that you have [created a load balancer](/cloud-servers/load-balancers/create-load-balancer.mdx) with an [HTTPS rule](/cloud-servers/load-balancers/about-load-balancers.mdx#rules) that will accept requests to the HTTPS version of the site. Available load balancers can be viewed in the [control panel](https://my.selectel.ru/vpc/default/lbaas/): in the top menu, click **Products** → **Cloud Servers** → **Load Balancers** → **Load Balancers** tab.

    2. In the [Control panel](https://my.selectel.ru/vpc/default/lbaas/load-balancers/), on the top menu, click **Products** and select **Cloud Servers**.

    3. Go to the **Load Balancers** section → **Load Balancers** tab.

    4. Open the load balancer page.

    5. Click **Create Rule**.

    6. Select the [protocol](/cloud-servers/load-balancers/about-load-balancers.mdx#protocols) for traffic reception — HTTP. The default port 80 will be automatically selected, on which the load balancer will listen for traffic.

    7. Select a [target group](/cloud-servers/load-balancers/about-load-balancers.mdx#target-groups) by default — traffic that does not fall under any [HTTP policies](/cloud-servers/load-balancers/about-load-balancers.mdx#http-policies) in the rule will be directed there. If there are no available target groups in the list, click **New target group** and [create a target group](/cloud-servers/load-balancers/target-groups/create-target-group.mdx) with the HTTP traffic destination protocol and port 80. If you want to drop traffic that does not fall under any HTTP policy, select **No target group**.

    8. Select the [HTTP request headers](/cloud-servers/load-balancers/about-load-balancers.mdx#http-request-headers) that need to be forwarded to servers.

    9. To create an [HTTP policy](/cloud-servers/load-balancers/about-load-balancers.mdx#http-policies) in the rule, click **Add new policy**.

    10. Select the condition check: **HOSTNAME** — **EQUAL TO**.

    11. Enter the domain name, for example `example.com`.

    12. Select the action **Redirect to URL prefix**.

    13. Enter the URL prefix — the part that will replace the protocol and domain name in the incoming request, for example `https://example.com`.

    14. Optional: change the policy name or leave the default one.

    15. Click **Add**.

    16. Optional: open the **Advanced rule settings** block and specify the [connection settings](/cloud-servers/load-balancers/about-load-balancers.mdx#connection-settings):

        * for incoming requests to the load balancer — specify the connection timeout and the maximum number of connections;
        * for requests from the load balancer to servers — specify the connection timeout, inactivity timeout, and TCP packet waiting timeout.

    17. Click **Create**.
  </TabItem>

  <TabItem value="openstack">
    <TabItemLabel>
      OpenStack CLI
    </TabItemLabel>

    1. Ensure that you have [created a load balancer](/cloud-servers/load-balancers/create-load-balancer.mdx) with an [HTTPS rule](/cloud-servers/load-balancers/about-load-balancers.mdx#rules) that will accept requests to the HTTPS version of the site. Available load balancers can be viewed using the `openstack loadbalancer list` command.

    2. [Open the OpenStack CLI](/cloud-servers/tools/openstack-cli/).

    3. Create a [rule](/cloud-servers/load-balancers/about-load-balancers.mdx#rules) for the load balancer with the HTTP protocol and port 80:

       ```bash
       openstack loadbalancer listener create \
         --name <listener_name> \
         --protocol HTTP \
         --protocol-port 80 \
         --default-pool <default_pool> \
         <loadbalancer>
       ```

       Specify:

       * `<listener_name>` — rule name;
       * optional: `--default-pool <default_pool>` — ID or name of the default [target group](/cloud-servers/load-balancers/about-load-balancers.mdx#target-groups) where traffic that does not fall under any [HTTP policies](/cloud-servers/load-balancers/about-load-balancers.mdx#http-policies) in the rule will be directed. The list of groups can be viewed using the `openstack loadbalancer pool list` command. If you do not have a suitable target group, [create one](/cloud-servers/load-balancers/target-groups/create-target-group.mdx). If this parameter is not specified, traffic not matching the rule will be dropped;
       * `<loadbalancer>` — load balancer ID or name. You can view the list using the `openstack loadbalancer list` command.

    4. Create an [HTTP policy](/cloud-servers/load-balancers/about-load-balancers.mdx#http-policies) in the rule:

       ```bash
       openstack loadbalancer l7policy create \
         --action REDIRECT_PREFIX \
         --redirect-prefix <prefix_domain_name> \
         --name <policy_name> \
         <listener>
       ```

       Specify:

       * `<prefix_domain_name>` — a domain of the type `https://example.com/`;
       * `<policy_name>` — L7 policy name;
       * `<listener>` — rule ID or name. You can view the list using the `openstack loadbalancer listener list` command.

    5. Create a condition in the HTTP policy:

       ```bash
       openstack loadbalancer l7rule create \
         --compare-type EQUAL_TO \
         --type HOST_NAME \
         --value <domain_name> \
         <policy>
       ```

       Specify:

       * `<domain_name>` — a domain of the type `example.com`;
       * `<policy>` — L7 policy ID or name. You can view the list using the `openstack loadbalancer l7policy list` command.
  </TabItem>
</Tabs>

<Formbricks />
