diff --git a/Procfile b/Procfile index 29fe166..49cc933 100644 --- a/Procfile +++ b/Procfile @@ -1,2 +1,2 @@ -dockergen: docker-gen -watch -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf +dockergen: docker-gen -watch${INCLUDE_STOPPED} -notify "nginx -s reload" /app/nginx.tmpl /etc/nginx/conf.d/default.conf nginx: nginx diff --git a/README.md b/README.md index 9e411f0..3a366fd 100644 --- a/README.md +++ b/README.md @@ -176,6 +176,15 @@ If you would like to connect to FastCGI backend, set `VIRTUAL_PROTO=fastcgi` on If you use fastcgi,you can set `VIRTUAL_ROOT=xxx` for your root directory +### Static File Backends + +If you want your container to only serve static content, set `VIRTUAL_PROTO=static` on the container. +You can then set `VIRTUAL_ROOT=xxx` to your static files' root directory. If your static files live in a stopped +container, be sure to set the `INCLUDE_STOPPED_CONTAINERS=true` environment variable on the nginx-proxy container as +stopped containers will otherwise be ignored. + +You can create a minimal docker container with your static website files in a volume. The volume can then be mounted +into the nginx-proxy container and be served with this "backend". ### Default Host diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 0e42880..716be78 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -14,6 +14,12 @@ if [[ $DOCKER_HOST = unix://* ]]; then fi fi +if [ "${INCLUDE_STOPPED_CONTAINERS}" == "true" ]; then + export INCLUDE_STOPPED=" -include-stopped" +else + export INCLUDE_STOPPED="" +fi + # Generate dhparam file if required /app/generate-dhparam.sh diff --git a/nginx.tmpl b/nginx.tmpl index e79f790..ee684cf 100644 --- a/nginx.tmpl +++ b/nginx.tmpl @@ -342,6 +342,8 @@ server { fastcgi_pass {{ trim $upstream_name }}; {{ else if eq $proto "grpc" }} grpc_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "static" }} + root {{ trim $vhost_root }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }} @@ -394,6 +396,8 @@ server { fastcgi_pass {{ trim $upstream_name }}; {{ else if eq $proto "grpc" }} grpc_pass {{ trim $proto }}://{{ trim $upstream_name }}; + {{ else if eq $proto "static" }} + root {{ trim $vhost_root }}; {{ else }} proxy_pass {{ trim $proto }}://{{ trim $upstream_name }}; {{ end }}