12/28/2021

Install Openssl In Docker Container

33

Once you have installed Kendis Docker and it's up and running, you can follow these steps to configure SSL.

Dec 11, 2018 What version of alpine are you using? There are no openssl 1.1.1 packages for alpine 3.8 (the latest stable version as of this writing). List of openssl packages for 3.8. If you really want to use the 1.1.1 for the edge version, you might want to. Download and install the edge package (i don't recommend that). Apr 27, 2020 Since one of the goals of using Docker is to avoid cluttering the local machine as much as possible, we'll use a container to install OpenSSL and generate the certificate. Nginx's is a logical choice for this – being our proxy, it will be the one receiving the encrypted traffic on port 443, before redirecting it to the right container.

Step 1: Create Directory

Create a directory with the name 'docker_ssl_proxy' to store the NGINX configuration file and the certificate and key

Step 2: Change directory to docker_ssl_proxy

You must be under this directory before executing the following steps (commands).

Step 2.a: Use Signed certificates

If you have certificates you can simply copy the following 2 files in the current directory
key.pem
cert.pem

Step 2.b Create the self-signed certificates (If needed)

Use OpenSSL to create a self-signed certificate, Following command will create a self-signed certificate and a private key with a validity of 365 days.

Step 3: Find your container IP address

3.1: Find your kendis container Id.

It will list all the processes that are running and find out your Kendis container id.

3.2 Find IP Address

Container

To find the container IP address from the host, you can run the command

<kendis-container-id>: replace this with the value that you get from Step 4.1

The response of the above command will be an IP address e.g.,

'123.12.2.1'

Step 4: Create the NGINX configuration file

In the same directory, create a configuration file that will proxy all the traffic to your upstream server. The upstream server is the application server running a non-SSL connection. The SSL will be using NGINX, and all the traffic will be proxied to the host (using the IP address that you got in Step 3.2)

The configuration file, which in this example is called 'proxy_ssl.conf,' but can have any name as long as it ends in .conf. The file must have the following contents

Example file: proxy_ssl.conf

The only thing you need to replace in this file is IP Address. We are using the example IP 123.12.2.1.

This file simply instructs NginX to listen, with SSL and the correct certs and keys, on port 443 and to proxy all the requests to the host on port 8080

Step 5: Run the docker container

At this point we have all the configuration in place to proxy the traffic, we simply need to run the docker container with the following command


NOTE: In case you face issues, try to replace PWD in the command above with the full directory path for 'docker_ssl_proxy', where you have config and cert files.


All Done.

Install Openssl In Docker Container Design

Just open a browser and hit the URL with HTTPS.

  • Most Viewed News

    • Macos 10.12 Iso
    • Macos Mojave Hackintosh Download
    • Start With Docker
    • Software El Capitan Download