Friday 25 September 2020

Host a SSL (https) website on Ubuntu

  Below are the steps to host a website on port 80. In the below example 172.16.1.11 is the IP adddress on the Ubuntu server which will receive the customer traffic.


Step 1 : Enable SSL and restart Apache services

sudo a2enmod ssl

sudo service apache2 restart

STEP 2: Create a directory which contatin the certifcate and key.

Sudo Su

mkdir /etc/apache2/ssl


STEP 3: Generate self sign certificate and key

openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt


STEP 2:  Create the index html file and add the HTML code in it

nano /var/www/html/172.16.1.12_all/index.html

<html>

<title>172.16.1.12_8080</title>

<h1>Welcome to 172.16.1.12_8080 Website</h1>

<p>Website on port 8080</p>

</html>

ctrl + X then press Y 

Press Enter


STEP 4:  Add below ServerName in apache2.conf file

/etc/apache2/apache2.conf file:

ServerName localhost


STEP 5:   Add the website to the "SITES-AVAILABLE" FOLDER.

nano /etc/apache2/sites-available/172.16.1.12_all_ssl.conf

<VirtualHost 172.16.1.12:443>

ServerAdmin admin@localhost

ServerName  172.16.1.12

DocumentRoot /var/www/html/172.16.1.12_all

DirectoryIndex index.html

SSLEngine on

SSLCertificateFile      /etc/apache2/ssl/apache.crt

SSLCertificateKeyFile /etc/apache2/ssl/apache.key

</VirtualHost>

ctrl + X then press Y 

Press Enter


STEP 6:  Publish the website on Ubuntu

sudo a2ensite 172.16.1.12_all_ssl


STEP 7:   Restart Apache service

sudo service apache2 restart

STEP 8:   Check the website syntax

apachectl configtest

1 comment:

  1. Technological advancements have greatly impacted communication, enabling instant global connectivity through the internet and various communication devices.123moviesfree

    ReplyDelete