Cloud
Ssl

Install frontend SSL on Instance

Apache SSL Configuration for your-domain

To enable HTTPS on your Apache server for the domain

www-yourdomain.com
, follow the steps below.

1. Enable SSL Module

To enable the SSL module for Apache, run the following command:

sudo a2enmod ssl

2. Generate or Install an SSL Certificate

You can either generate a self-signed SSL certificate or use one from a trusted Certificate Authority (CA). To generate a self-signed certificate, run:

sudo mkdir /etc/apache2/ssl
sudo openssl req -x509 -nodes -days 365 -newkey "your username" -keyout /etc/apache2/ssl/apache.key -out /etc/apache2/ssl/apache.crt
This will create the SSL certificate and key at the following paths:
 
/etc/apache2/ssl/apache.key
/etc/apache2/ssl/apache.crt

3. Configure Apache to Listen on Port 443

Edit the Apache configuration file to enable listening on port 443. Use the following command to modify the /etc/apache2/sites-available/default-ssl.conf file:

sudo nano /etc/apache2/sites-available/default-ssl.conf
Ensure the following configuration is present in the default-ssl.conf file:
<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html
 
    SSLEngine on
    SSLCertificateFile      /etc/apache2/ssl/apache.crt
    SSLCertificateKeyFile   /etc/apache2/ssl/apache.key
</VirtualHost>

4. Enable SSL Site Configuration

Enable the default SSL site configuration in Apache:

sudo a2ensite default-ssl.conf

5. Open Port 443 in the Firewall

Make sure that port 443 is open for incoming traffic. Use the following command to allow Apache Full through the firewall:

sudo ufw allow 'Apache Full'

6. Restart Apache

Finally, restart Apache to apply the changes:

sudo systemctl restart apache2