Configure Apache to serve https

Enable mod ssl

sudo a2enmod ssl

Listen port 443

edit /etc/apache2/ports.conf and add

NameVirtualHost *:443

Generate certificate

openssl genrsa -out ca.key 2048

openssl req -new -key ca.key -out ca.csr

openssl x509 -req -days 365 -in ca.csr -signkey ca.key -out ca.crt

Config virtual host

thevirtual host looks similar to port 80 but also has 3 SSL configurations below

SSLEngine on

SSLCertificateFile /etc/apache2/ssl/ca.crt

SSLCertificateKeyFile /etc/apache2/ssl/ca.key

ref:

- การติดตั้งและใช้งาน SSL (HTTPS) บน Apache Web Server