diff options
-rw-r--r-- | .docker/envvars.sh | 14 | ||||
-rw-r--r-- | .docker/lighttpd.conf | 11 | ||||
-rw-r--r-- | Dockerfile | 7 |
3 files changed, 29 insertions, 3 deletions
diff --git a/.docker/envvars.sh b/.docker/envvars.sh new file mode 100644 index 0000000..71f47e1 --- /dev/null +++ b/.docker/envvars.sh @@ -0,0 +1,14 @@ +#! /usr/bin/env sh + +main() +{ + mkvar intendedHost "${INTENDED_HOST:-localhost}" + mkvar intendedHostProto "${INTENDED_HOST_PROTO:-http}" +} + +mkvar() +{ + printf 'var.%s="%s"\n' "$1" "$2" +} + +main "$@" diff --git a/.docker/lighttpd.conf b/.docker/lighttpd.conf index 132ad29..c8f6f72 100644 --- a/.docker/lighttpd.conf +++ b/.docker/lighttpd.conf @@ -1,4 +1,7 @@ -server.modules += ( "mod_setenv" ) +server.modules += ( + "mod_setenv", + "mod_redirect", +) setenv.add-response-header = ( "Content-Security-Policy" => "default-src 'self'; img-src https:; object-src 'self'; script-src 'self'; style-src 'self'", @@ -8,3 +11,9 @@ setenv.add-response-header = ( "X-Permitted-Cross-Domain-Policies" => "none", "X-XSS-Protection" => "1; mode=block", ) + +include_shell "/usr/local/bin/lighttpd-env.sh" + +$HTTP["host"] != var.intendedHost { + url.redirect = ( "^/(.*)" => var.intendedHostProto + "://" + var.intendedHost + "/$1" ) +} @@ -1,4 +1,7 @@ -FROM tyil/http-static +FROM registry.gitlab.com/tyil/docker-http-static:latest COPY _site /var/www -COPY .docker/lighttpd.conf /etc/lighttpd/custom.conf +COPY .docker/envvars.sh /usr/local/bin/lighttpd-env.sh +COPY .docker/lighttpd.conf /etc/lighttpd/custom.d/lighttpd.conf + +RUN chmod +x /usr/local/bin/lighttpd-env.sh |