A quick note of enabling SSL for Apache Web Server.

Test environment: Ubuntu 20.04 LTS (Focal Fossa) 64-bit

Generate SSL Certificates

Navigate to the target directory, for example /root/sys/ssl, and generate private key:

openssl req -new -newkey rsa:2048 -nodes -out nassgeodata_gmu_edu.crt -keyout nassgeodata_gmu_edu.key -subj "/C=US/ST=Virginia/L=Fairfax/O=George Mason University/OU=CSISS/CN=nassgeodata.gmu.edu"

After requested the certificate, for example /root/sys/ssl/sslcerts/x509CO/nassgeo_csiss_gmu_edu_cert.cer, create symbolic link of the certificate file:

ln -s /root/sys/ssl/sslcerts/x509CO/nassgeo_csiss_gmu_edu_cert.cer /root/sys/ssl/nassgeodata_gmu_edu.cer 

Enable SSL

Configure Apache Web Server

Create symbolic link of SSL config file:

ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/000-default-ssl.conf

Edit /etc/apache2/sites-enabled/000-default-ssl.conf and add:

SSLCertificateFile      /root/sys/ssl/nassgeodata_gmu_edu.cer
SSLCertificateKeyFile   /root/sys/ssl/nassgeodata_gmu_edu.key

Enable rewrite mod and restart Apache:

sudo a2enmod ssl
service apache2 restart

Redirect HTTP to HTTPS (Optional)

Edit /etc/apache2/sites-enabled/000-default.conf and add:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]

Enable rewrite mod and restart Apache:

sudo a2enmod rewrite
service apache2 restart

References

https://hallard.me/enable-ssl-for-apache-server-in-5-minutes/

https://www.tecmint.com/redirect-http-to-https-on-apache/