Available Architectures: amd64, arm64, 386, arm/v7, arm/v6
This image is based on the official Nginx Docker image and extends it with the ability to have virtual hosts created automatically, as well as adding SSL certificates when creating new directories. For that to work, it integrates two tools that will take care about the whole process: watcherd and vhost-gen.
From a users perspective, you mount your local project directory into the container under /shared/httpd. Any directory then created in your local project directory wil spawn a new virtual host by the same name. Additional settings such as custom server names, PHP-FPM or even different Apache templates per project are supported as well.
HTTP/2 is enabled by default for all SSL connections.
๐ฑ GitHub: devilbox/docker-nginx-stable
| Web Server Project | Reference Implementation |
|---|---|
![]() | ![]() |
| Streamlined Webserver images | The Devilbox |
Apache 2.2 | Apache 2.4 | Nginx stable | Nginx mainline
docker pull devilbox/nginx-stableThe following Docker image tags are rolling releases and are built and updated every night.
| Docker Tag | Git Ref | Available Architectures |
|---|---|---|
latest | master | amd64, i386, arm64, arm/v7, arm/v6 |
debian | master | amd64, i386, arm64, arm/v7, arm/v6 |
alpine | master | amd64, i386, arm64, arm/v7, arm/v6 |
The following Docker image tags are built once and can be used for reproducible builds. Its version never changes so you will have to update tags in your pipelines from time to time in order to stay up-to-date.
| Docker Tag | Git Ref | Available Architectures |
|---|---|---|
<tag> | git: <tag> | amd64, i386, arm64, arm/v7, arm/v6 |
<tag>-debian | git: <tag> | amd64, i386, arm64, arm/v7, arm/v6 |
<tag>-alpine | git: <tag> | amd64, i386, arm64, arm/v7, arm/v6 |
๐ Where
<tag>refers to the chosen git tag from this repository.
โ Warning: The latest available git tag is also build every night and considered a rolling tag.
๐ For details see Documentation: Features
Virtual hosts are created automatically, simply by creating a new project directory (inside or outside of the container). This allows you to quickly create new projects and work on them in your IDE without the hassle of configuring the web server.
PHP is not included in the provided images, but you can link the Docker container to a PHP-FPM image with any PHP version. This allows you to easily switch PHP versions and choose one which is currently required.
SSL certificates are generated automatically for each virtual host to allow you to develop over HTTP and HTTPS.
SSL certificates are signed by a certificate authority (which is also being generated). The CA file can be mounted locally and imported into your browser, which allows you to automatically treat all generated virtual host certificates as trusted.
Each virtual host can individually be fully customized via vhost-gen templates.
The default virtual host is also treated differently from the auto-generated mass virtual hosts. You can choose to disable it or use it for a generic overview page for all of your created projects.
Through virtual host customization, any project can also be served with a reverse proxy. This is useful if you want to run NodeJS or Python projects which require a reverse proxy and still want to benefit with a custom domain and auto-generated SSL certificates.
File system permissions of files/dirs inside the running Docker container are synced with the permission on your host system. This is accomplished by specifying a user- and group-id to the docker run command.
The provided Docker images add a lot of injectables in order to customize it to your needs. See the table below for a brief overview.
๐ For details see Documentation: Environment variables
| Nginx | Logging | Features |
|---|---|---|
WORKER_CONNECTIONSWORKER_PROCESSESHTTP2_ENABLE | DEBUG_ENTRYPOINTDEBUG_RUNTIMEDOCKER_LOGS | TIMEZONENEW_UIDNEW_GID |
| Main vHost | Mass vHost | PHP |
MAIN_VHOST_ENABLEMAIN_VHOST_SSL_TYPEMAIN_VHOST_SSL_GENMAIN_VHOST_SSL_CNMAIN_VHOST_DOCROOTMAIN_VHOST_TPLMAIN_VHOST_STATUS_ENABLEMAIN_VHOST_STATUS_ALIAS | MASS_VHOST_ENABLEMASS_VHOST_SSL_TYPEMASS_VHOST_SSL_GENMASS_VHOST_TLDMASS_VHOST_DOCROOTMASS_VHOST_TPL | PHP_FPM_ENABLEPHP_FPM_SERVER_ADDRPHP_FPM_SERVER_PORTPHP_FPM_TIMEOUT |
The provided Docker images offer the following internal paths to be mounted to your local file system.
๐ For details see Documentation: Volumes
| Data dir | Config dir |
|---|---|
/var/www/default//shared/httpd/ | /etc/httpd-custom.d//etc/vhost-gen.d/ |
When you plan on using 443 you should enable automated SSL certificate generation.
| Docker | Description |
|---|---|
| 80 | HTTP listening Port |
| 443 | HTTPS listening Port |
Mount your local directort ~/my-host-www into the container and server those files.
Note: Files will be server from ~/my-host-www/htdocs.
docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default \ devilbox/nginx-stable| PHP-FPM Reference Images |
|---|
![]() |
Note, for this to work, the ~/my-host-www dir must be mounted into the Nginx container as well as into the php-fpm container. Each PHP-FPM container also has the option to enable Xdebug and more, see their respective Readme files for futher settings.
# Start the PHP-FPM container, mounting the same diectory docker run -d -it \ --name php \ -p 9000 \ -v ~/my-host-www:/var/www/default \ devilbox/php-fpm:5.6-prod # Start the Nginx Docker, linking it to the PHP-FPM container docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default \ -e PHP_FPM_ENABLE=1 \ -e PHP_FPM_SERVER_ADDR=php \ -e PHP_FPM_SERVER_PORT=9000 \ --link php \ devilbox/nginx-stableSame as above, but also add a MySQL container and link it into Nginx.
# Start the MySQL container docker run -d -it \ --name mysql \ -p 3306:3306 \ -e MYSQL_ROOT_PASSWORD=my-secret-pw \ devilbox/mysql:mysql-5.5 # Start the PHP-FPM container, mounting the same diectory. # Also make sure to # forward the remote MySQL port 3306 to 127.0.0.1:3306 within the # PHP-FPM container in order to be able to use `127.0.0.1` for mysql # connections from within the php container. docker run -d -it \ --name php \ -p 9000:9000 \ -v ~/my-host-www:/var/www/default \ -e FORWARD_PORTS_TO_LOCALHOST=3306:mysql:3306 \ devilbox/php-fpm:5.6-prod # Start the Nginx Docker, linking it to the PHP-FPM container docker run -d -it \ -p 80:80 \ -v ~/my-host-www:/var/www/default \ -e PHP_FPM_ENABLE=1 \ -e PHP_FPM_SERVER_ADDR=php \ -e PHP_FPM_SERVER_PORT=9000 \ --link php \ --link mysql \ devilbox/nginx-stableShow some love for the following sister projects.
In case you seek help, go and visit the community pages.
| | | |
| devilbox.readthedocs.io | discord/devilbox | devilbox.discourse.group |
I try to keep up with literally over 100 projects besides a full-time job. If my work is making your life easier, consider contributing. ๐ค
Findme: ๐ฑ cytopia / devilbox | ๐ cytopia / devilbox | ๐ฆ everythingcli / devilbox | ๐ everythingcli.org
Contrib: PyPI: cytopia ยท Terraform: cytopia ยท Ansible: cytopia
Copyright (c) 2016 cytopia




