Configure HTTP → HTTPS redirect
Control panel
OpenStack CLI
-
Make sure that created a load balancer с HTTPS rule which will accept requests to the HTTPS version of the site. Available balancers can be viewed in control panels under Cloud platform →Balancers.
-
В control panels go to Cloud platform → Balancers.
-
Open the tab Balancers → balancer page.
-
Click Create a rule.
-
Select protocol The default port 80 will be automatically selected. The standard port 80 will be automatically selected, on which the balancer will listen to traffic.
-
Select target group By default, traffic that is not subject to the HTTP Policies in the rule. If there are no available target groups in the list, tap New target group и create a task force with the HTTP traffic destination protocol and port 80. If you want to discard traffic that does not fall under the HTTP policy, select Without a target group.
-
Mark it HTTP request headers that need to be transmitted to the servers.
-
To create in the rule HTTP policy, press Add a new policy.
-
Select a test condition: HOSTNAME — EQUAL TO.
-
Enter the name of the domain, for example,
example.com
. -
Select an action Redirect to URL prefix.
-
Enter the URL prefix — the part that will replace the protocol and domain name in the incoming request, for example,
https://example.com
. -
Optional: change the policy name or leave the default one generated.
-
Click Add.
-
Optional: open the unit Advanced rule settings and specify connection settings:
- for incoming requests to the balancer — specify the connection timeout and maximum connections;
- for requests from the balancer to servers — specify the connection timeout, inactivity timeout and TCP packet waiting timeout.
-
Click Create.
-
Make sure that created a load balancer с HTTPS rule which will accept requests to the HTTPS version of the site. Available balancers can be viewed using the command
openstack loadbalancer list
-
Create rule for a balancer with HTTP protocol and port 80:
openstack loadbalancer listener create \
--name <listener_name> \
--protocol HTTP \
--protocol-port 80 \
--default-pool <default_pool> \
<loadbalancer>Specify:
<listener_name>
— NAME OF RULE;- optional:
--default-pool <default_pool>
— ID or name target group The default destination for traffic that is not covered by the HTTP Policies in the rule. The list of groups can be viewed withopenstack loadbalancer pool list
. If you don't have the right target group, create it. If you do not specify a parameter, traffic not covered by the rule will be discarded; <loadbalancer>
— ID or name of the load balancer. You can view the list using the commandopenstack loadbalancer list
-
Create HTTP policy in the rule:
openstack loadbalancer l7policy create \
--action REDIRECT_PREFIX \
--redirect-prefix <prefix_domain_name> \
--name <policy_name> \
<listener>Specify:
<prefix_domain_name>
— type domainhttps://example.com/
;<policy_name>
— L7-policy name;<listener>
— ID or name of the rule. The list can be viewed withopenstack loadbalancer listener list
-
Create a condition in the HTTP policy:
openstack loadbalancer l7rule create \
--compare-type EQUAL_TO \
--type HOST_NAME \
--value <domain_name> \
<policy>Specify:
<domain_name>
— type domainexample.com
;<policy>
— ID or name of the L7 policy. The list can be viewed withopenstack loadbalancer l7policy list