From 271d616cb155460d3c364de0ace1fbc37419a3ec Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Tue, 22 Oct 2019 12:20:04 +0200 Subject: Attempt to do redirection from lighttpd --- .docker/envvars.sh | 14 ++++++++++++++ .docker/lighttpd.conf | 11 ++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 .docker/envvars.sh (limited to '.docker') 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" ) +} -- cgit v1.1