Skip to content

Instantly share code, notes, and snippets.

@AugustKarlstedt
Created September 25, 2018 01:56
Show Gist options
  • Save AugustKarlstedt/bfed23bef4c2f081d574b4286b8a66bb to your computer and use it in GitHub Desktop.
Save AugustKarlstedt/bfed23bef4c2f081d574b4286b8a66bb to your computer and use it in GitHub Desktop.
Enabled HTTPS in WordPress Docker Container

Originally posted by @ajdruff at docker-library/wordpress#46 (comment)

  1. expose port 443 by adding the following to your compose file:

      ports:
        - "443:443"       
    
  2. restart your container (be sure your db and web files are on persistent storage!)

     docker-compose down
     docker-compose up -d
    
  3. attach to the running container

       docker exec -t -i CONTAINER_ID /bin/bash
    
  4. install ssl-cert ( automatically installs self-signed cert)

     apt-get update && \
         apt-get install -y  --no-install-recommends ssl-cert && \
         rm -r /var/lib/apt/lists/* && \
         a2enmod ssl && \
         a2ensite default-ssl
    

You may get a prompt about restarting apache before the new settings take effect.

  service apache2 reload
  1. exit the container (won't kill your container)

     CTRL-P-Q
    
  2. Access your https://example.com , adding an exception to your browser to ignore the prompt about untrusted CA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment