Skip to content

Instantly share code, notes, and snippets.

@zalexki
Last active October 23, 2020 10:06
Show Gist options
  • Select an option

  • Save zalexki/5cdfe4bf67db65f891028aea7467931b to your computer and use it in GitHub Desktop.

Select an option

Save zalexki/5cdfe4bf67db65f891028aea7467931b to your computer and use it in GitHub Desktop.
Docker Apache2.4 HTTPS
Open port 443 on container.
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 red.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 server.cert.prem.
Copy them in proper folder during container build:
```
COPY ssl/cert.pem /etc/ssl/certs/cert.pem
COPY ssl/cert.key /etc/ssl/certs/cert.key
RUN echo '' > /etc/apache2/ports.conf
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment