title: Cannot get SSL to work in Docker container
body: <p>Let me start off by saying that I am no server administrator and there are a great many things I do not know. Because of this I am sure that I have made a mistake somewhere setting up my Docker container, because SSL does not work. </p>
  
  <p>The container is running Apache 2.4 with PHP 5.6 on Ubuntu 14.04 and is linked to a MySQL 5.6 Docker container. </p>
  
  <p>I started with this basic setup from Docker - <a href="https://hub.docker.com/_/php/" rel="noreferrer">Official PHP Repo</a>. Here are the relevant files:</p>
  
  <p><strong>Dockefile</strong></p>
  
  <pre><code>FROM php:5.6-apache
  
  RUN apt-get update
  RUN apt-get install -y net-tools
  RUN docker-php-ext-install pdo pdo_mysql
  RUN docker-php-ext-install sockets
  
  RUN a2enmod rewrite
  RUN a2enmod ssl
  
  ADD 000-default.conf /etc/apache2/sites-enabled/
  ADD default-ssl.conf /etc/apache2/sites-anabled/
  ADD apache2.conf /etc/apache2/
  ADD www-server/ www-server/
  
  EXPOSE 443
  </code></pre>
  
  <p><strong>000-default.conf</strong></p>
  
  <pre><code>&lt;VirtualHost *:80&gt;
  
      ServerAdmin webmaster@localhost
      DocumentRoot /www-server/
  
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
  
  &lt;/VirtualHost&gt;
  
  &lt;Directory /home/www-server/&gt;
      # allow .htaccess overrides to work
      AllowOverride All
      DirectoryIndex login.html index.html index.php
  &lt;/Directory&gt;
  
  &lt;Directory /home/www-server/client&gt;
      DirectoryIndex home.html
      Options All
      AllowOverride All
      Require all granted
  &lt;/Directory&gt;
  </code></pre>
  
  <p><strong>default-ssl.conf</strong></p>
  
  <pre><code>&lt;IfModule mod_ssl.c&gt;
      &lt;VirtualHost _default_:443&gt;
          ServerAdmin webmaster@localhost
          DocumentRoot /home/www-server
  
          ErrorLog ${APACHE_LOG_DIR}/error.log
          CustomLog ${APACHE_LOG_DIR}/access.log combined
  
          # Enable/Disable SSL for this virtual host.
          SSLEngine on
  
          SSLCertificateFile /etc/ssl/certs/site.crt
          SSLCertificateKeyFile /etc/ssl/certs/site.key
          SSLCACertificatePath /etc/ssl/certs/digicert/
  
       &lt;/VirtualHost&gt;
  &lt;/IfModule&gt;
  </code></pre>
  
  <p><strong>apache2.conf</strong></p>
  
  <pre><code>Mutex file:/var/lock/apache2 default
  PidFile /var/run/apache2/apache2.pid
  Timeout 300
  KeepAlive On
  MaxKeepAliveRequests 100
  KeepAliveTimeout 5
  User www-data
  Group www-data
  HostnameLookups Off
  ErrorLog /proc/self/fd/2
  LogLevel warn
  
  IncludeOptional mods-enabled/*.load
  IncludeOptional mods-enabled/*.conf
  
  # ports.conf
  Listen 80
  &lt;IfModule ssl_module&gt;
          Listen 443
  &lt;/IfModule&gt;
  &lt;IfModule mod_gnutls.c&gt;
          Listen 443
  &lt;/IfModule&gt;
  
  &lt;Directory /&gt;
          Options FollowSymLinks
          AllowOverride None
          Require all denied
  &lt;/Directory&gt;
  
  &lt;Directory /home/www-server/&gt;
      Options Indexes FollowSymLinks Includes ExecCGI
      AllowOverride All
      Require all granted
  &lt;/Directory&gt;
  
  DocumentRoot /home/www-server
  
  AccessFileName .htaccess
  &lt;FilesMatch "^\.ht"&gt;
          Require all denied
  &lt;/FilesMatch&gt;
  
  LogFormat "%v:%p %h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
  LogFormat "%h %l %u %t \"%r\" %&gt;s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
  LogFormat "%h %l %u %t \"%r\" %&gt;s %O" common
  LogFormat "%{Referer}i -&gt; %U" referer
  LogFormat "%{User-agent}i" agent
  
  CustomLog /proc/self/fd/1 combined
  
  &lt;FilesMatch \.php$&gt;
          SetHandler application/x-httpd-php
  &lt;/FilesMatch&gt;
  
  # Multiple DirectoryIndex directives within the same context will add
  # to the list of resources to look for rather than replace
  # https://httpd.apache.org/docs/current/mod/mod_dir.html#directoryindex
  DirectoryIndex disabled
  DirectoryIndex index.php index.html
  
  IncludeOptional conf-enabled/*.conf
  IncludeOptional sites-enabled/*.conf
  </code></pre>
  
  <p><strong>NOTE</strong>: I have removed non-relevant parts of these files.</p>
  
  <p>To run the Docker container I use this:</p>
  
  <pre><code>sudo docker run -v /home/src/ssl-cert:/etc/ssl/certs --name app-gateway --link mysql56:mysql -p 80:80 -p 443:443 -d  app-image
  </code></pre>
  
  <p>Here is a section of the log files:</p>
  
  <pre><code>::1 - - [10/Nov/2015:19:26:19 +0000] "OPTIONS * HTTP/1.0" 200 152 "-" "Apache/2.4.10 (Debian) PHP/5.6.15 OpenSSL/1.0.1k (internal dummy connection)"
  ::1 - - [10/Nov/2015:19:26:20 +0000] "OPTIONS * HTTP/1.0" 200 152 "-" "Apache/2.4.10 (Debian) PHP/5.6.15 OpenSSL/1.0.1k (internal dummy connection)"
  72.5.190.136 - - [10/Nov/2015:19:26:21 +0000] "\x16\x03\x01" 400 0 "-" "-"
  72.5.190.136 - - [10/Nov/2015:19:26:21 +0000] "\x16\x03\x01" 400 0 "-" "-"
  72.5.190.136 - - [10/Nov/2015:19:26:21 +0000] "\x16\x03\x01" 400 0 "-" "-"
  </code></pre>
  
  <p>With this error in the browser:</p>
  
  <blockquote>
    <p>ERR_SSL_PROTOCOL_ERROR</p>
  </blockquote>
  
  <p><strong>TL;DR</strong>
  I have followed all of the steps that I have found online to install and use my SSL certificates in a Docker container but I have had no success in making it work. Is there anything obvious I've overlooked to make SSL work in a Docker container?</p>