Terminating TLS connections
- Prepare your cloud
- Create a cloud network
- Reserve a static public IP address
- Create security groups
- Import the site's TLS certificate into Certificate Manager
- Create a VM group for the site
- Upload the site files to the VM
- Create a backend group
- Create and configure an HTTP router
- Create an L7 load Balancer
- Check that the hosting is running properly
- Delete the resources you created
Application Load Balancer L7 load balancers can terminate TLS connections: send certificates to clients, decrypt incoming traffic to send to the backends, and encrypt backend responses to forward to clients. This scenario describes configuring a load balancer to terminate TLS connections using a certificate from Certificate Manager and to redirect HTTP requests to HTTPS.
This scenario uses my-site.com
as an example domain name.
To create a virtual hosting:
- Prepare your cloud.
- Create a cloud network.
- Reserve a static public IP address.
- Create security groups.
- Import the site's TLS certificate into Certificate Manager.
- Create a VM group for the site.
- Upload the site files to the VM.
- Create a backend group.
- Create and configure an HTTP router.
- Create an L7 load balancer.
- Check that the hosting is running properly.
If you no longer need the resources you created, delete them.
Prepare your cloud
Sign up for Nebius Israel and create a billing account:
- Go to the management console
and log in to Nebius Israel or create an account if you do not have one yet. - On the Billing
page in the management console, make sure you have a billing account linked and it has theACTIVE
orTRIAL_ACTIVE
status. If you do not have a billing account, create one.
If you have an active billing account, you can go to the cloud page
Learn more about clouds and folders.
Required paid resources
The cost of virtual hosting includes:
- Fee for continuously running virtual machines (see Compute Cloud pricing).
- A fee for using a public static IP address (see Virtual Private Cloud pricing).
Create a cloud network
All resources you have created in the tutorial belong to the same cloud network.
To create a network:
- In the management console
, select Virtual Private Cloud. - Click Create network.
- Enter a Name for the network:
mysite-network
. - In the Advanced field, select Create subnets.
- Click Create network.
Reserve a static public IP address
For your virtual hosting to run, you need to assign a static public IP address to the L7 load balancer.
To reserve an address:
- In the management console
, select Virtual Private Cloud. - Open the IP addresses tab. Click Reserve address.
- In the window that opens, select the
il1-a
availability zone. Click ** Reserve**.
Create security groups
Security groups include rules that allow the load balancer to receive incoming traffic and redirect it to the VMs so they can receive the traffic. In this use case, we will create two security groups: one for the load balancer and another one for all VMs.
To create security groups:
-
In the management console
, select Virtual Private Cloud. -
Open the Security groups tab.
-
Create a security group for the load balancer:
-
Click Create group.
-
Enter a Name for the group:
mysite-sg-balancer
. -
Select the Network:
mysite-network
. -
Under Rules, create the following rules using the instructions below the table:
Traffic
directionDescription Port range Protocol Source /
destinationCIDR blocks Outgoing
any
All
Any
CIDR
0.0.0.0/0
Incoming
ext-http
80
TCP
CIDR
0.0.0.0/0
Incoming
ext-https
443
TCP
CIDR
0.0.0.0/0
Incoming
healthchecks
30080
TCP
Load balancer healthchecks
N/A -
Select the Egress or Ingress tab.
-
Click Add rule.
-
In the Port range field of the window that opens, specify a single port or a range of ports that traffic will come to or from.
-
In the Protocol field, specify the appropriate protocol or leave
Any
to allow traffic transmission over any protocol. -
In the Destination name or Source field, select the purpose of the rule:
CIDR
: Rule will apply to the range of IP addresses. In the CIDR blocks field, specify the CIDR and masks of subnets that traffic will come to or from. To add multiple CIDRs, click Add CIDR.Security group
: Rule will apply to the VMs from the current group or the selected security group.Load balancer healthchecks
: Rule that allows a load balancer to check the health of VMs.
-
Click Save. Repeat the steps to create all the rules from the table.
-
-
Click Save.
-
-
In the same way, create a security group named
mysite-sg-vms
for the VM and a network namedmysite-network
with the following rules:Traffic
directionDescription Port range Protocol Source /
destinationCIDR blocks Incoming
balancer
80
TCP
Security group
mysite-sg-balancer
Incoming
ssh
22
TCP
CIDR
0.0.0.0/0
Import the site's TLS certificate into Certificate Manager
For users to access the site using the secure HTTPS protocol (HTTP over TLS), the site must have a TLS certificate issued. For use in the L7 load balancer, import the certificate into Certificate Manager.
If your site does not have a certificate, you can use to get a Certificate Managercertificate from Let's Encrypt®. This does not require additional steps after creating a certificate. It is imported automatically.
To import an existing certificate for my-site.com
:
- In the management console
, select Certificate Manager. - Click Add certificate and select the User certificate option.
- Enter a Name for the certificate:
mysite-cert
. - In the Certificate field, click Add certificate. Upload the File with your certificate or enter its Content and click Add.
- If your certificate is issued by a third-party certificate authority, click Add chain in the Intermediate certificate chain field. Upload the File with the certificate chain or enter its Content and click Add.
- In the Private key field, click Add private key. Upload the File with the key or enter its Content and click Add.
- Click Create.
Create a VM group for the site
To create a VM group for my-site.com
:
-
In the management console
, select Compute Cloud. -
Open the Instance groups tab. Click Create group.
-
Specify a VM group name:
mysite-ig
. -
Under Allocation, select multiple availability zones to ensure fault tolerance of your hosting.
-
Under Instance template, click Define.
-
Under Image/boot disk selection, open the Cloud Marketplace tab and click Show more. Select LEMP and click Use.
-
Under Computing resources:
- Select the VM's platform.
- Specify the required number of vCPUs and the amount of RAM.
The minimum configuration is enough for functional website testing:
- Platform:
Intel Cascade Lake
- Guaranteed vCPU performance:
5%
- vCPU:
2
- RAM:
1 GB
-
Under Network settings, select the Network named
mysite-network
that you created earlier and its subnets. -
Select the previously created
mysite-sg-vms
security group. -
Specify the data required for accessing the VM:
-
Enter the username in the Login field.
-
In the SSH key field, paste the contents of the public key file.
You need to create a key pair for the SSH connection yourself. See Connecting to a VM via SSH.
Alert
The IP address and host name (FQDN) to connect to the VM are assigned at VM creation. If you selected No address in the Public address field, you will not be able to access the VM from the internet.
-
-
Click Save.
-
Under Scaling, enter the Size of the instance group: 2.
-
Under Integration with Application Load Balancer, select Create target group and specify
mysite-tg
as the group name. You can read more about target groups here. -
Click Create.
It may take a few minutes to create an instance group. When the group status changes to RUNNING
and the status of all its VMs to RUNNING_ACTUAL
, you can upload the website files to them.
Upload the site files to the VM
To test the web servers, upload the index.html
files to the virtual machines.
<!DOCTYPE html>
<html>
<head>
<title>My site</title>
</head>
<body>
<h1>This is my site</h1>
</body>
</html>
To upload a file to a VM:
-
Under Network on the VM page in the management console
, find the VM public IP address. -
Connect to the VM via SSH.
-
Grant your user write access to the
/var/www/html
directory:UbuntuCentOSsudo chown -R "$USER":www-data /var/www/html
sudo chown -R "$USER":apache /var/www/html
-
Upload the website files to the VM via SCP
.Linux/macOSWindowsUse the
scp
command-line utility:scp -r <path to the file directory> <VM username>@<VM IP address>:/var/www/html
Use WinSCP
to copy the local file directory to/var/www/html
on the VM.
Create a backend group
You must link the target group created with the VM group to the backend group that defines traffic allocation settings.
For the backends, groups will implement health checks: the load balancer will periodically send health check requests to the VMs and expect a response after a certain delay.
To create a backend group for my-site.com
:
- In the management console
, select Application Load Balancer. - Open the Backend groups tab. Click Create backend group.
- Enter a Name for the backend group:
my-site-bg
. - Under Backends, click Add.
- Enter a Name for the backend:
mysite-backend
. - In the Target groups field, select the
mysite-tg
group. - Specify the Port that the backend VMs will use to receive incoming traffic from the load balancer:
80
. - Click Add health check.
- Specify the Port that the backend VMs will use to accept health check connections:
80
. - Enter the Path to be accessed by the load balancer for health checks:
/
. - Click Create.
Create and configure an HTTP router
The backend group should be linked to an HTTP router that defines routing rules.
To create an HTTP router:
- In the management console
, select Application Load Balancer. - Open the HTTP routers tab. Click Create HTTP router.
- Enter a Name for the HTTP router:
mysite-router
. - Click Add virtual host.
- Enter a Name for the virtual host:
mysite-host
. - In the Authority field, specify the site domain name:
my-site.com
. - Click Add route.
- Enter a Name for the route:
mysite-route
. - In the Backend group field, select the
my-site-bg
group. - Click Create.
Create an L7 load Balancer
-
In the management console
, select Application Load Balancer. -
Click Create L7 load balancer.
-
Enter a Name for the load balancer:
mysite-alb
. -
Under Network settings, select the
mysite-sg-balancer
security group that you previously created. -
Create a listener to redirect HTTP requests to HTTPS:
- Under Listeners, click Add listener.
- Enter a Name for the listener:
listener-http
. - Under Public IP address, select the
List
type and the IP address you reserved earlier. - In the Protocol field, select
Redirect to HTTPS
.
-
Create an HTTPS request listener:
-
Click Add listener again.
-
Enter a Name for the listener:
listener-https
. -
Under Public IP address, select the
List
type and the IP address you reserved earlier. -
In the Protocol field, select
HTTPS
. -
Under Main listener, select the
mysite-cert
certificate and themysite-router
HTTP router. -
Add an SNI match for
my-site.com
:- Click Add SNI match.
- Specify the Name for the SNI match:
mysite-sni
. - In the Server names field, enter
my-site.com
. - Select the
mysite-cert
certificate and themysite-router
HTTP router.
-
-
Click Create.
Check that the hosting is running properly
To check that your hosting is functional, open the website at http://my-site.com
in your browser. A redirect to https://my-site.com
should occur with the TLS certificate from Certificate Manager already enabled.
Delete the resources you created
To shut down the hosting and stop paying for the created resources: