Skip to content

Multiple docker-compose examples behind jwilder:nginx-proxy

License

Notifications You must be signed in to change notification settings

LuisEnMarroquin/compose-webservices

Repository files navigation

compose-webservices

Multiple webservices using docker-compose behind nginx-proxy

Create .env file

Create a file to store your environment variables

# Email for letsencrypt cert renew
EMAIL=me@localhost.com
# You server's domain name
DOMAIN=localhost.com

Start services

At first you need to start the nginx service, it includes nginx, letsencrypt and whoami containers

docker-compose -p nginx -f docker-compose.yml  up -d --force-recreate --remove-orphans

Coder

docker-compose -p code -f docker-code.yml up -d --build --force-recreate --remove-orphans

Gitlab

docker-compose -p gitlab -f docker-gitlab.yml up -d --force-recreate --remove-orphans

Jenkins

docker-compose -p jenkins -f docker-jenkins.yml up -d --force-recreate --remove-orphans

Netdata

docker-compose -p netdata -f docker-netdata.yml up -d --force-recreate --remove-orphans

Portainer

docker-compose -p portainer -f docker-portainer.yml up -d --force-recreate --remove-orphans

Generate new htpasswd, edit command property on docker-portainer.yml

docker run --rm httpd:2.4-alpine htpasswd -nbB admin <password> | cut -d ":" -f 2
  • If any password passed though cli has an $ you must escape it using double $$

Node

A simple docker-compose example combining Nginx, Node and Mongo, this works by itself and shouldn't run with the other nginx instance. This part was obtained from this post.

docker-compose -p node -f docker-node.yml up -d --force-recreate --remove-orphans

Test if it works locally

Use cURL it works you'll see the something like I'm 999999999:

curl -H "Host: whoami.localhost.com" localhost

If you have Windows or macOS add the following on:

  • macOS: /etc/hosts
  • Windows: C:\Windows\System32\drivers\etc\hosts
127.0.0.1 localhost.com
127.0.0.1 code.localhost.com
127.0.0.1 whoami.localhost.com
127.0.0.1 gitlab.localhost.com
127.0.0.1 jenkins.localhost.com
127.0.0.1 netdata.localhost.com
127.0.0.1 portainer.localhost.com
127.0.0.1 wordpress.localhost.com
127.0.0.1 db.wordpress.localhost.com

Then visit whoami.localhost.com` with your favorite browser

Digital Ocean

Create a Droplet

Watch large workspace VSCode