docker-nginx-dynamic-sites
docker-nginx-dynamic-sites copied to clipboard
Serve static sites based on their domain using Docker & NGINX
trafficstars
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.
How does it work?
- 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.
Usage
To run it:
$ docker run -d -p 80:80 -v /path/to/sites:/sites/ teonite/nginx-dynamic-sites
Log files
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.
