This documentation covers the setting up of virtual hosts on a server running on the Ubuntu Linux operating system. It is assumed that a local computer running Linux is being used to set up the remote server. If not then some of the steps may be different. The explanation is split into three stages:
Launch Server using a ‘User Data’ Bash script.
Amazon Web Services’ (AWS) Elastic Cloud Compute (EC2) service will be used to launch an instance of Ubuntu. The Bash script will install the Apache web server configured for two virtual hosts. Configuring more virtual hosts is simply a question of repeating the relevant steps. We can now access the default HTML document on the server from a web browser using the IPv4 address of the server and the (insecure) Hyper Text Transfer Protocol (http).
This is the bash script which can be supplied to the EC2 instance launch process as user data. Alternatively it can be used as a guide for the commands to be used when connected by SSH to the server after it has been launched.
Register domains and create DNS records
AWS’s Route 53 service will be used to show how to register domains and how to create DNS records that point them to the content they relate to on the server.
Install Certificates Using Certbot
Installing Let’s Encrypt certificates onto the server for each domain using the Certbot program will be covered. This enables the virtual hosts to be reached by Hyper Text Transfer Protocol Secure (https) requests. The certificates give assurance that the content accessed by a given domain is controlled by the owner of the domain. They are necessary for Transport Layer Security (TLS) which is part of the secure, https, protocol. Now we can access the content on the server from a browser using the domain names in the address bar with https.