title: Nginx SSL inside a docker container
body: <p>I have configured a Docker container to run Nginx and setup the /etc/nginx/sites-available/default file as shown below</p>
  
  <pre><code>server 
  {
   listen 80 default_server;
   listen [::]:80 default_server ipv6only=on;
  
   root /usr/share/nginx/html;
   index index.php index.html index.htm;
  
   server_name example.com;
  
   location / {
              try_files $uri $uri/ /index.html;
      }
  
      error_page 404 /404.html;
  
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
            root /usr/share/nginx/html;
      }
  
  
      location ~ \.php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   
          include fastcgi_params;
   }
  
  }
  
  server 
  {
   listen 443;
  
   root /usr/share/nginx/html;
   index index.php index.html index.htm;
  
   server_name example.com;
  
   ssl    on;
   ssl_certificate    /etc/ssl/certs/ssl-cert-snakeoil.pem;
   ssl_certificate_key    /etc/ssl/private/ssl-cert-snakeoil.key;
  
  
   location / {
              try_files $uri $uri/ /index.html;
      }
  
      error_page 404 /404.html;
  
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
            root /usr/share/nginx/html;
      }
  
  
  location ~ \.php$ {
          try_files $uri =404;
          fastcgi_split_path_info ^(.+\.php)(/.+)$;
      fastcgi_pass unix:/var/run/php5-fpm.sock;
      fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;   
          include fastcgi_params;
   }
  
  
  }
  </code></pre>
  
  <p>I map the /etc/ssl/certs &amp; /etc/ssl/private folders on the host when I run the docker container</p>
  
  <pre><code>docker run -dt -p 8080:443 -p 8081:80 -v /t-base/log:/var/log/nginx -v
  /etc/ssl/certs:/etc/ssl/certs -v /etc/ssl/private:/etc/ssl/private nginx
  
  Docker ps shows
  
  Up n minutes 0.0.0.0:8081-&gt;80/tcp 0.0.0.0:8080-&gt;443/tcp &lt;container-name&gt;
  </code></pre>
  
  <p>and the nginx error log file inside the mapped /t-base/log folder stays empty.  </p>
  
  <pre><code>docker exec -it &lt;container-name&gt; /bin/bash
  </code></pre>
  
  <p>followed by </p>
  
  <pre><code>service nginx status
  </code></pre>
  
  <p>just comes back and says that nginx is running.</p>
  
  <p>All of the above would indicate that everything is working correctly.  However, I find that whilst I am able to browse to </p>
  
  <pre><code>http://example.com:8080
  </code></pre>
  
  <p>turns up the default page</p>
  
  <pre><code>https://example.com:8081
  </code></pre>
  
  <p>has the Chrome showing me its default "sad smiley" error page.  I cannot see what I might be doing wrong here.  I'd much appreciate any help.</p>