This image can be configured by modifying environment variables at container startup. Feel free to contribute ;)
# PHP FPM
FPM=false
FPM_HOST=app
FPM_PORT=9000
FPM_TIMEOUT_READ=60s
FPM_TIMEOUT_SEND=60s
# Reverse proxy
PROXY=false
PROXY_PROTO=http
PROXY_HOST=app
# uWSGI
UWSGI=false
UWSGI_HOST=app
UWSGI_PORT=9000
# SSL termination
SSL=false
SSL_CERT=/ssl/cert.pem
SSL_KEY=/ssl/key.pem
SSL_TIMEOUT=5m
# Location options
LOCATION=/
LOCATION_MODE=root
LOCATION_PATH=/var/www/html
LOCATION_INDEX="index.php index.html index.htm"
LOCATION_AUTOINDEX=false
#
# Custom config lines
#
# before main `server {}`
CONFIG_GLOBAL_START_0=""
CONFIG_GLOBAL_START_1=""
CONFIG_GLOBAL_START_...=""
# after main `server {}`
CONFIG_GLOBAL_END_0=""
CONFIG_GLOBAL_END_1=""
CONFIG_GLOBAL_END_...=""
# before main `location {}`
CONFIG_SERVER_0=""
CONFIG_SERVER_1=""
CONFIG_SERVER_...=""
# inside main `location {}`
CONFIG_LOCATION_0=""
CONFIG_LOCATION_1=""
CONFIG_LOCATION_...=""
docker run -it --rm -v www:/var/www/html -p 80:80 thedrhax/nginx-stateless
docker run -it --rm -v www:/var/www/html -p 80:80 -e LOCATION_AUTOINDEX=true -e LOCATION_INDEX="" thedrhax/nginx-stateless
docker run -it --rm -v www:/var/www/html -p 80:80 -e FPM=true -e FPM_HOST=your.fpm.host thedrhax/nginx-stateless
docker run -it --rm -p 80:80 -e PROXY=true -e PROXY_HOST=another.server thedrhax/nginx-stateless
docker run -it --rm -v ssl:/ssl -p 443:443 -e SSL=true -e SSL_CERT=/path/to/cert.pem -e SSL_KEY=/ssl/key.pem thedrhax/nginx-stateless
You can also combine SSL termination with all previous examples.
docker run -it --rm -p 80:80 -e CONFIG_GLOBAL_END_0="server { server_name b.example.com; return 301 \$scheme://a.example.com$request_uri; }" thedrhax/nginx-stateless
docker run -it --rm -p 80:80 -e CONFIG_GLOBAL_START_0="server { return 301 \$scheme://a.example.com$request_uri; }" -e CONFIG_SERVER_0="server_name a.example.com;" thedrhax/nginx-stateless
You can add custom lines to server{} and location{} blocks by setting CONFIG_SERVER_*
and CONFIG_LOCATION_*
. Number of the first line must be 0.
docker run --it --rm -v www:/var/www/html -p 81:81 -e CONFIG_SERVER_0="listen 81;" thedrhax/nginx-stateless