Open port 443 on container, with a docker-compose file just add :
ports:
- 443:443
Add virtualhost config :
Listen 443 https
<VirtualHost *:443>
# Enable/Disable SSL for this virtual host.
SSLEngine on
SSLCertificateFile /etc/ssl/certs/cert.pem
SSLCertificateKeyFile /etc/ssl/certs/cert.key
</VirtualHost>
Create files with openssl and following config file named req.cnf :
openssl req -x509 -nodes -days 99999 -newkey rsa:2048 -keyout cert.key -out cert.pem -config req.cnf -sha256
[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
[req_distinguished_name]
C = FR
ST = IDF
L = Clichy
O = SensioGrey
OU = PoleTech
CN = sodebo.mydocker
[v3_req]
keyUsage = critical, digitalSignature, keyAgreement
extendedKeyUsage = serverAuth
subjectAltName = @alt_names
[alt_names]
DNS.1 = www.sodebo.mydocker
DNS.2 = fr.sodebo.mydocker
DNS.3 = en.sodebo.mydocker
This will generate a key.pem and cert.prem.
Copy them in proper folder during container build (to add in Dockerfile):
COPY ssl/cert.pem /etc/ssl/certs/cert.pem
COPY ssl/cert.key /etc/ssl/certs/cert.key
RUN echo '' > /etc/apache2/ports.conf
We delete default ports apache2 configuration, be sure to add Listen 80
in virtualhost config if you still use non https version.