This image allows configuring the public path, which is served by Nginx, and the name of the service and port that receives the traffic.
- Docker Registry: getstackhead/nginx
- GitHub Registry: docker.pkg.github.com/getstackhead/dockerimages/nginx
Customization can be done by setting environment variables. The default values for those vary by image (see below).
| Environment variable | Description |
|---|---|
| DOCKER_PROXY_SERVICE_NAME | Name of Docker service |
| DOCKER_PROXY_SERVICE_PORT | Port to receive the HTTP request |
| NGINX_PUBLIC_DIRECTORY | Folder containing files to be served |
The tags describe which files Nginx can process and forward to the respective service.
- standalone (Dockerfile)
- NGINX_PUBLIC_DIRECTORY=html
- NGINX_LISTEN_PORT=8080
- php (Dockerfile)
- DOCKER_PROXY_SERVICE_NAME=php
- DOCKER_PROXY_SERVICE_PORT=9000
- NGINX_PUBLIC_DIRECTORY=html
- NGINX_LISTEN_PORT=8080
# from Docker registry
FROM getstackhead/nginx:php
# from GitHub registry
FROM docker.pkg.github.com/getstackhead/dockerimages/nginx:phpservices:
nginx:
image: getstackhead/nginx:php
environment:
DOCKER_PROXY_SERVICE_NAME: phpfpm # name of PHP service (default: php)
NGINX_PUBLIC_DIRECTORY: htdocs # folder containing files to be served (default: www)
volumes:
- .:/var/www # Nginx serves /var/www/$NGINX_PUBLIC_DIRECTORY
links:
- phpfpm
phpfpm:
image: php:7.4-fpm
# ...deployment:
type: docker
settings:
services:
- name: data
image: mydatacontainer
- name: nginx
image: getstackhead/nginx:php
environment:
DOCKER_PROXY_SERVICE_NAME: phpfpm # name of my php service below is phpfpm
NGINX_PUBLIC_DIRECTORY: htdocs # files are in /var/www/htdocs (mounted from mydatacontainer)
volumes_from:
- data
links:
- phpfpm
- name: phpfpm
image: php:7.4-fpm
# ... more configuration here...