Updated: 11 August 2024
I often create and edit Customer demo apps, with Docker. I’ve found it very useful to serve all of these apps behind one Nginx reverse proxy webserver. The notes below show how I achieve this with the Digital Ocean Nginx config tool and deployment of the config with git.
Getting started
- Create a Digital Ocean LEMP Droplet.
- Install Docker on the LEMP Droplet.
- Install and run your Docker applications, binding each to a different host port.
Domains
Each demo needs a URL which can be given to the Customer. I tend to use subdomains of my business domain e.g. http://a-demo.christaylordeveloper.co.uk. For each subdomain I configure an A-record, pointing at the IP address of the LEMP server.
NGINXConfig
- Create nginx config for your site(s) with this Digital Ocean tool https://www.digitalocean.com/community/tools/nginx
- On the Reverse proxy tab, insert into the proxy_pass field the port numbers you set earlier when running-up your docker apps.
- Download your Nginx config.
Git
- Make a local git repo of the downloaded config and push to a remote.
- Add to your repo a .gitignore file which will ignore everything else in the LEMP droplet /etc/nginx directory.
- Clone the git repo into the LEMP server
/etc/nginx/
directory - Restart the Nginx service.
Edits
At some point you will need to add, edit or remove the Docker applications:
- Load the URL in file
nginxconf.txt
. This restores your configuration into the Digital Ocean tool. - Make the required edits and download again.
- Commit the changes into your local git repo and push to remote.
- Pull changes into your LEMP server.