Configure HTTP → HTTPS redirect
Control panel
OpenStack CLI
-
Make sure to create a load balancer with an HTTPS rule that will accept requests to the HTTPS version of the site. Available load balancers can be viewed in the Control Panel: in the top menu, click Products → Cloud Servers → Balancers → Balancers tab.
-
In the dashboard, on the top menu, click Products and select Cloud Servers.
-
Go to Balancers → Balancers tab.
-
Open the balancer page.
-
Click Create Rule.
-
Select HTTP as the protocol for receiving traffic. The default port 80 will be automatically selected, on which the balancer will listen to traffic.
-
Select the default target group — traffic that is not covered by the 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 with the HTTP traffic destination protocol and port 80. If you want to discard traffic that does not fall under the HTTP policy, select No Target Group.
-
Mark the HTTP request headers to be passed to the servers.
-
To create an HTTP policy in the rule, click Add New Policy.
-
Select the check condition: HOSTNAME — EQUAL TO.
-
Enter a domain name, such as
example.com
. -
Select the Redirect to URL prefix action.
-
Enter the URL prefix — the part that will replace the protocol and domain name in the incoming request, e.g.
https://example.com
. -
Optional: change the policy name or leave the default one generated.
-
Click Add.
-
Optional: open the Advanced Rule Settings block and specify the 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 to create a load balancer with an HTTPS rule that will accept requests to the HTTPS version of the site. You can view available load balancers using the
openstack loadbalancer list
command. -
Create a rule for the 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>
— rule name;- optional:
--default-pool <default_pool>
— ID or name of the default target group, where the traffic not covered by HTTP policies in the rule will be directed. You can view the list of groups using theopenstack loadbalancer pool list
command . If you do not have a suitable target group, create one. If you do not specify a parameter, traffic that does not fall under the rule will be discarded; <loadbalancer>
— The ID or name of the load balancer. The list can be viewed with the commandopenstack loadbalancer list
.
-
Create an 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>
— domain of the formhttps://example.com/
;<policy_name>
— L7 policy name;<listener>
— The ID or name of the rule. The list can be viewed with the commandopenstack 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>
— domain of the formexample.com
;<policy>
— The ID or name of the L7 policy. The list can be viewed with the commandopenstack loadbalancer l7policy list
.