Krishnan's Personal Website

Home | About | Blog | Interesting Reads | Tutorials | Skills | Personal Projects | Books | Fun | Connect with me

Creating virtual hosts and SSL

Published On: Jul 01 2023
Written By: Krishnan Sethuraman
Category: Building Chuckle

Creating virtual hosts (vhost)

I had to create the web space on the server where the source code will be stored. I created them inside /var/www.

Created virtual host for both the domains. 

I created two virtual hosts. One for the frontend site and the second one for the api. 

$ cd /etc/apache2/sites-available/
$ cp 000-default.conf
$ vi 

I repeated the same steps for api-chuckle virtual host. 

$ cp 000-default.conf
$ vi 

Once the virtual host files were created I enabled the virtual hosts and restarted apache. 

$ a2ensite
$ a2ensite
$ systemctl reload apache2

Configuring https with Letsencrypt

For https I used Letsencrypt. Certboot was already installed on my server so straight away ran the commands to enable https. 

$ certbot --apache -d
$ certbot --apache -d

Running certboot for the api vhost gave me an error. While troubleshooting I realized that I had misspelled the dns entry while creating the dns records. I logged into the dns service portal and corrected the same. I had to wait for a few minutes for the propagation before running certboot for api vhost again. 

Creating a temporary landing page 

As mentioned in the previous posts I will be using Github Actions for CI/CD but I am not going to configure right right now. So I logged into the server and manually created the landing pages. 

The landing pages are simple html pages with the coming soon text. 

Application URLs