DEV Community

Cover image for Host a website on Azure Virtual Machine with SSL enabled using Let's Encrypt & add a custom domain managed by Azure DNS.
Surya Shankar
Surya Shankar

Posted on • Updated on

Host a website on Azure Virtual Machine with SSL enabled using Let's Encrypt & add a custom domain managed by Azure DNS.

Create a Virtual machine and install a web server

Image description
Image description
Image description

Now connect this servers with xshell.

Image description

Here we are going to install apache server

apt install apache2
Enter fullscreen mode Exit fullscreen mode

Image description

We can use Github commands to clone our website code from our repo ,so You need to install git.

apt install git -y
Enter fullscreen mode Exit fullscreen mode

we have to clone that repo to our web server folder name [ html ] as follow

Image description

[In case if we stop and start our server , we need start our apache again , to avoid this we can simply enable that server]

Image description

Now paste the public ip in the browser and you will see your website.[Not fully secure]

Image description

How to attach a domain name

you require a free or purchased domain to fully complete all the steps. If you already have a domain, then awesome, if not, don't worry, you can get a free domain! You can visit the following site and get yourself a free domain.

https://www.freenom.com/en/index.html?lang=en

Enter fullscreen mode Exit fullscreen mode

Image description

Once you sort out your domain, you should go back to the Azure console and navigate to the AZURE DNS service.

Image description

Create a DNS zone

Azure DNS is a hosting service for DNS domains that provides name resolution by using Microsoft Azure infrastructure.
By hosting your domains in Azure, you can manage your DNS records by using the same credentials, APIs, tools, and billing as your other Azure.

You have to make sure to enter the exact domain name as shown below

Image description

After that put this name server inside your domain name server [freenom]

Image description
Image description

You can alse add a record set as shown below.

Image description

Now our domain is fully binds with our public ip.

Image description

But its not Secure

Image description

How To Secure Apache with Let's Encrypt on Ubuntu.

Let’s Encrypt is a Certificate Authority (CA) that gives a simple method to acquire and introduce free TLS/SSL declarations, along these lines empowering encoded HTTPS on web servers.
It rearranges the procedure by giving a product customer, Certbot, that endeavors to mechanize most (if not the entirety) of the necessary advances.

Step 1: Update System

sudo apt-get update 
Enter fullscreen mode Exit fullscreen mode

Image description

Step 2: Install Certbot

sudo certbot --apache -d cloud167.ml -d www.cloud167.ml
Enter fullscreen mode Exit fullscreen mode

Its auto verify the domain and its will create all required files to configure in virtualhost ssl parameter, After installation and configuration, You will get the successful message, Now you can access with yours domain like this.

Image description

Type 2

Image description

Here we have successfully installed and configure lets encrypt valid certificate with apache web server

Image description

Paste your domain name in browser as shown below its fully secured now

Image description
Image description

Oldest comments (0)