Skip to content

Devilbox's Nginx stable (based on official Nginx Docker) [multi-arch]

License

devilbox/docker-nginx-stable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Nginx stable

release Github lint build nightly License

Discord Discourse

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


๐Ÿ‹ Available Docker tags

latest debian alpine

docker pull devilbox/nginx-stable

Rolling releases

The following Docker image tags are rolling releases and are built and updated every night.

nightly

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

Point in time releases

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.

build

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.

โœฐ Features

๐Ÿ›ˆ For details see Documentation: Features

Automated virtual hosts

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.

Automated PHP-FPM setup

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.

Automated SSL certificate generation

SSL certificates are generated automatically for each virtual host to allow you to develop over HTTP and HTTPS.

Automatically trusted 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.

Customization per virtual host

Each virtual host can individually be fully customized via vhost-gen templates.

Customization for the default virtual host

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.

Reverse Proxy integration

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.

Local file system permission sync

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.

โˆ‘ Environment Variables

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_CONNECTIONS
WORKER_PROCESSES
HTTP2_ENABLE
DEBUG_ENTRYPOINT
DEBUG_RUNTIME
DOCKER_LOGS
TIMEZONE
NEW_UID
NEW_GID
Main vHost Mass vHost PHP
MAIN_VHOST_ENABLE
MAIN_VHOST_SSL_TYPE
MAIN_VHOST_SSL_GEN
MAIN_VHOST_SSL_CN
MAIN_VHOST_DOCROOT
MAIN_VHOST_TPL
MAIN_VHOST_STATUS_ENABLE
MAIN_VHOST_STATUS_ALIAS
MASS_VHOST_ENABLE
MASS_VHOST_SSL_TYPE
MASS_VHOST_SSL_GEN
MASS_VHOST_TLD
MASS_VHOST_DOCROOT
MASS_VHOST_TPL
PHP_FPM_ENABLE
PHP_FPM_SERVER_ADDR
PHP_FPM_SERVER_PORT
PHP_FPM_TIMEOUT

๐Ÿ“‚ Volumes

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/

๐Ÿ–ง Exposed Ports

When you plan on using 443 you should enable automated SSL certificate generation.

Docker Description
80 HTTP listening Port
443 HTTPS listening Port

๐Ÿ’ก Examples

Serve static files

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

Serve PHP files with PHP-FPM

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-stable

Fully functional LEMP stack

Same 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-stable

๐Ÿ–ค Sister Projects

Show some love for the following sister projects.

๐Ÿ–ค Project ๐Ÿฑ GitHub ๐Ÿ‹ DockerHub
Devilbox
docker-php-fpm devilbox/php-fpm
docker-php-fpm-community devilbox/php-fpm-community
docker-mysql devilbox/mysql
docker-apache-2.2
docker-apache-2.4
docker-nginx-stable
docker-nginx-mainline
devilbox/apache-2.2
devilbox/apache-2.4
devilbox/nginx-stable
devilbox/nginx-mainline

๐Ÿ‘ซ Community

In case you seek help, go and visit the community pages.

devilbox.readthedocs.io discord/devilbox devilbox.discourse.group

๐Ÿง˜ Maintainer

@cytopia

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

๐Ÿ—Ž License

MIT License

Copyright (c) 2016 cytopia

About

Devilbox's Nginx stable (based on official Nginx Docker) [multi-arch]

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors 3

  •  
  •  
  •