Part 2: Install SSL certificates for websites
Install SSL certificates for websites can encrypt and secure communications between the web server and the client browser, preventing criminals from reading or modifying information transferred.
Step 1. Register domain names
info
Please ignore this steps if you have your own domain name.
With a domain name, users can quickly access to your website by typing an easy and memorable name rather than a rigid IP address!
You may register a free or paid Domain Name according to your needs. In this tutorial, we use No-IP to demonstrate the process of registering a free domain name.
- Sign up for No-IP account.
- Click My Services on the left panel > DNS Records > click Create HostName after login.
- Set the Hostname (Domain Name): twccservice1.ddns.net
- Set the IP Address: Enter your VCS Public IP address.
- Click Add Hostname to complete the registration.
- You may use NsLookup to query the host (load balancer)
- Enter Domain Name
- Click go
- If the request success, the answer records will be shown as below
- Repeat the steps above and setting the Hostname (Domain Name):
twccservice2.ddns.net
Step 2. Create SSL certificates for websites
- Please install Certbot as the tool of creating SSL certificates for websites.
apt install certbot python3-certbot-nginx
- Enter the domain name of service1
certbot --nginx -d <Domain_Name>
info
Replace
<Domain_Name>
with the domain name you've just registered.Enter e-mail to receive emergency or safety notice.
- Please choose
2
, to redirect HTTP traffic to HTTPs, and remove HTTP access.
- Enter Nginx config file and modify the root folder corresponding of website service2.
vim /etc/nginx/sites-available/default
- Press i key to enter edit mode and replace the
root /var/www/html/service1
toroot /var/www/html/service2
- When done, press Esc key to exit edit mode and enter
:wq!
command and press Enter key to save and exit. - Please repeat Step 2 to create a SSL certificate for website service2.
info
Please ignore installing the certbot and starts from setting the domain name.