This demo shows how to host several websites (running inside Docker containers) on a single server and automatically create/renew SSL certificates to enable HTTPS on each website.
To achieve that we can use:
- nginxproxy/nginx-proxy: Automated Nginx reverse proxy for docker containers. Together with nginx it generates its reverse proxy configs and reloads nginx when containers are started and stopped.
- nginxproxy/acme-companion: Automated ACME SSL certificate generation for nginx-proxy. It handles the automated creation, renewal and use of SSL certificates for proxied Docker containers through the ACME protocol.
- Make sure that your server has
git,dockeranddocker composeinstalled and nobody listen port80. - Clone this repository:
git clone https://github.com/halfdata/multisite-docker.git
- Jump into
multisite-dockerfolder/directory:
cd multisite-docker
- Edit
nginx-proxy/docker-compose.ymland set your email address as a value ofDEFAULT_EMAILenvironment variable innginx-proxy-acmecontainer. This email is used to get SSL certificates from Letsencrypt. - Edit
domain1.tld/docker-compose.yml,domain2.tld/docker-compose.yml,domain3.tld/docker-compose.ymland set required values ofVIRTUAL_HOSTandLETSENCRYPT_HOSTenvironment variables (domains pointing to the IP of the server). - Make file
run.shexecutable:
chmod +x run.sh
- Start deployment:
./run.sh
That's it.