diff --git a/Dockerfile b/Dockerfile index 29c76aa..c0a11af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,6 +48,11 @@ ADD root/usr /usr ADD root/etc /etc ADD root/system-docker-entrypoint.d/wwwroot.sh /system-docker-entrypoint.d/10-wwwroot.sh +# Add configuration for SSL. +ADD root/system-docker-entrypoint.d/ssl.sh /system-docker-entrypoint.d/20-ssl.sh +ADD root/etc/apache2/conf-enabled/certificate.conf /etc/apache2/conf-enabled/certificate.conf +EXPOSE 443 + # Fix the original permissions of /tmp, the PHP default upload tmp dir. RUN chmod 777 /tmp && chmod +t /tmp diff --git a/root/etc/apache2/conf-enabled/certificate.conf b/root/etc/apache2/conf-enabled/certificate.conf new file mode 100644 index 0000000..d97469d --- /dev/null +++ b/root/etc/apache2/conf-enabled/certificate.conf @@ -0,0 +1,5 @@ +Alias "/certificates" "/var/www/certificates" + + Require all granted + + diff --git a/root/system-docker-entrypoint.d/ssl.sh b/root/system-docker-entrypoint.d/ssl.sh new file mode 100644 index 0000000..157a334 --- /dev/null +++ b/root/system-docker-entrypoint.d/ssl.sh @@ -0,0 +1,17 @@ +echo +echo "#######################################" +echo "# moodle-php-apache ssl setup" +echo "#######################################" +echo "#" +echo "# Setting up Apache DocumentRoot" +openssl req -x509 -nodes -days 365 \ + -newkey rsa:2048 \ + -keyout /etc/ssl/private/ssl-cert-snakeoil.key \ + -out /etc/ssl/certs/ssl-cert-snakeoil.pem \ + -subj "/C=AU/ST=WA/L=Perth/O=Security/OU=Development/CN=example.com" + +a2ensite default-ssl +a2enmod ssl + +mkdir /var/www/certificates +cp /etc/ssl/certs/ssl-cert-snakeoil.pem /var/www/certificates/certificate.pem