4 Setting up SSL on wordpress container
Theodotos Andreou edited this page 2016-09-17 09:35:31 +03:00

Execute a shell on the container

docker exec -ti wordpress /bin/bash

NOTE: avoid typing exit to exit the container. Better use ctrl+p+q.

Add backports repo

cat >> /etc/apt/sources.list << EOF
deb http://ftp.debian.org/debian jessie-backports main
EOF

Install certbot

apt update
apt-get install python-certbot-apache -t jessie-backports

Commit the changes up to now

docker commit wordpress ellak-cy/wordpress-with-certbot
docker stop wordpress

Start the new container with 443 enabled

docker run -d --name wordpress-certbot --link mysql:mysql -p 80:80 -p 443:443 ellak-cy/wordpress-with-certbot
050ed584d54045595fa64cfc5b2be804e5a9a622f18f7e79411fb21d69a4233d

Install the certificates

certbot --text -d ellak.org -d www.ellak.org --email "admins@ellak.org"

-------------------------------------------------------------------------------
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.1.1-August-1-2016.pdf. You must agree
in order to register with the ACME server at
https://acme-v01.api.letsencrypt.org/directory
-------------------------------------------------------------------------------
(A)gree/(C)ancel: A
```

We were unable to find a vhost with a ServerName or Address of www.ellak.org.
Which virtual host would you like to choose?
(note: conf files with multiple vhosts are not yet supported)
-------------------------------------------------------------------------------
1: default-ssl.conf               |                       | HTTPS |
2: 000-default.conf               |                       |       | Enabled
3: 000-default-le-ssl.conf        | ellak.org             | HTTPS | Enabled
-------------------------------------------------------------------------------
Select the appropriate number [1-3] then [enter] (press 'c' to cancel): 3

Please choose whether HTTPS access is required or optional.
-------------------------------------------------------------------------------
1: Easy - Allow both HTTP and HTTPS access to these sites
2: Secure - Make all requests redirect to secure HTTPS access
-------------------------------------------------------------------------------
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2