docker-nginx-dynamic-sites is a simple solution to have one NGINX docker/container instance for multiple domains (virtual hosts).
The only thing you need to do is:
- Launch the contener
- Set all domain names to the IP that the container is exposed
- Put all your sites to /sites/ (volume exposed) directory with the domain names.
- detects and "creates" a virtual host based on the requested URL domain
- tries to find a folder with the domain name in the
/sites/
directory (eg./sites/domainname.com
) - If the folder exists, site is served - if not, the default one is served (
/sites/default
)
We've created this simple solution, as our whole infrastructure runs on Docker - and we wanted to have only one NGINX instance for all static sites.
To run it:
$ docker run -d -p 80:80 -v /path/to/sites:/sites/ teonite/nginx-dynamic-sites
There is only one error log file (/var/log/nginx/error.log
). Access logs are created with domain name eg. /var/log/nginx/domainname.com.access.log
.