Nginx is an ideal way of hiding plain http based sites, or providing centralised management to a bunch of individual docker hosted web applications. Presented here in this How-To is a simple deployement which can be replicated on any VPS or self hosted home server.
The pre-requisites are simply that docker is installed and operational on the server, there are many How-To's on that subject including one here.
First I would prepare the host system by creating the appropriate folders to store the containers data etc. Obviously you may choose somewhere different, but you must change the appropriate settings later in this How-To.
sudo mkdir -p /docker/nginx-proxy/data
Once we have the folder for storing data, we can create the script to download and create the docker container.
sudo vi /docker/nginx-proxy/create-nginx-proxy.sh
The following provides a script (really a single command) to create the container. I use the jlesage image on docker hub in this How-To. Others are available but the jlesage container has worked perfectly for me with multiple deployments.
docker run -d \ --name=nginx-proxy-manager \ -p 127.0.0.1:8181:8181 \ -p 80:8080 \ -p 43:4443 \ -v /docker/nginx-proxy/data:/config:rw \ jlesage/nginx-proxy-manager
You may notice that for the port mapping, we have specified the IP address of 127.0.0.1 for port 8181. This is so that the management interface of the proxy manager isn't available on the public internet. To reach that management interface I use a simple SSH tunnel so I don't have to rely on just password authentication of the container for security. The other TCP ports 80 and 443 for HTTP and HTTPs respectively are just mapped through docker to the host.
Once up and running, you can set up a SSH tunnel to the host machine by using the command below but substituting your own username and IP address:
ssh firstname.lastname@example.org -L 8181:127.0.0.1:8181
This will allow you to point your web browser to http://127.0.0.1:8181 and then access the admin screen.
The default username is email@example.com with the default password of changeme. :)
That's All Folks.