Skip to main content
Configure HTTP → HTTPS redirect
Last update:

Configure HTTP → HTTPS redirect

You can configure HTTP → HTTPS redirect.

HTTP requests from port 80 will be redirected to port 443.

  1. Create load balancer.

  2. Open OpenStack CLI.

  3. Create a Listener, a rule for a balancer with HTTP protocol and port 80:

    openstack loadbalancer listener create \
    --name <listener_name> \
    --protocol HTTP \
    --protocol-port 80 \
    <loadbalancer>

    Specify:

    • <listener_name> is the listener's name;
    • <loadbalancer> — ID or name of the load balancer, can be viewed via openstack loadbalancer list
  4. To display the rule correctly in the control panel, you need to create a Pool and a default Member — traffic not covered by the L7 policy will be redirected there.

    Create a Pool — add the HTTP protocol for the server to the rule and specify the algorithm:

    openstack loadbalancer pool create \
    --name <pool_name> \
    --lb-algorithm <algorithm> \
    --loadbalancer <loadbalancer> \
    --protocol HTTP

    Specify:

    • <pool_name> is the pool name;
    • <algorithm> is the name of the algorithm: ROUND_ROBIN or LEAST_CONNECTIONS;
    • <loadbalancer> — ID or name of the load balancer, can be viewed via openstack loadbalancer list
  5. Create Member — add the server to the rule and specify its IP address:

    openstack loadbalancer member create \
    --subnet-id <subnet_id> \
    --address <server_ip> \
    --protocol-port 80 \
    <pool>

    Specify:

    • <subnet_id> — ID of private or public subnet, can be viewed with openstack subnet list;
    • <server_ip> — IP address of the server;
    • <pool> — pool name or ID, can be viewed with openstack loadbalancer pool list
  6. Create an L7 policy in the created listener:

    openstack loadbalancer l7policy create \
    --action REDIRECT_TO_URL \
    --redirect-url <domain_name> \
    --name <policy_name> \
    <listener>

    Specify:

    • <domain_name> is a domain of the form https://example.com/;
    • <policy_name> is the name of the L7 policy;
    • <listener> — listener ID or name, can be viewed with openstack loadbalancer listener list
  7. Create an L7 rule in the L7 policy:

    openstack loadbalancer l7rule create {
    --compare-type EQUAL_TO {
    --type HOST_NAME {
    --value <domain_name> {
    <policy>

    Specify:

    • <domain_name> is a domain of the form https://example.com/;
    • <policy> — ID or name of the L7policy, can be viewed with openstack loadbalancer l7policy list