Skip to content
Permalink
Browse files

10551 FIX Docker container: Fix URL redirects when accessing /

When updating a Checkmk docker container instance from 1.5* to 1.6 the web
interface is not reachable using the top level URL "/" nor the "/cmk/" URL.
This worked only when setting up completely new container instances with 1.6.

With this werk the redirects now work as intended after an update.

CMK-3075

Change-Id: I41996a410d4092ffb82fc28e18861a0b5d3ec708
  • Loading branch information
LarsMichelsen committed Nov 22, 2019
1 parent 1f61fb3 commit 78d2811e79189d2857a0a028e591a77876f4cd9c
Showing with 33 additions and 12 deletions.
  1. +16 −0 .werks/10551
  2. +1 −1 docker/Makefile
  3. +16 −11 docker/docker-entrypoint.sh
@@ -0,0 +1,16 @@
Title: Docker container: Fix URL redirects when accessing /
Class: fix
Compatible: compat
Component: core
Date: 1574421810
Edition: cre
Knowledge: undoc
Level: 1
State: unknown
Version: 1.7.0i1

When updating a Checkmk docker container instance from 1.5* to 1.6 the web
interface is not reachable using the top level URL "/" nor the "/cmk/" URL.
This worked only when setting up completely new container instances with 1.6.

With this werk the redirects now work as intended after an update.
@@ -77,7 +77,7 @@ image-daily: needed-packages
else \
BRANCH_PREFIX="$${BRANCH_PREFIX}-" ; \
fi ; \
VERSION="$$(date +%F)" ; \
VERSION="$${VERSION:-$$(date +%F)}" ; \
VERSION="$${BRANCH_PREFIX}$${VERSION//-/.}" ; \
docker build \
--network=container:$$SECRET_CONTAINER_ID \
@@ -17,6 +17,20 @@ function exec_hook() {
fi
}

function create_system_apache_config() {
# We have the special situation that the site apache is directly accessed from
# external without a system apache reverse proxy. We need to disable the canonical
# name redirect here to make redirects work as expected.
#
# In a reverse proxy setup the proxy would rewrite the host to the host requested by the user.
# See omd/packages/apache-omd/skel/etc/apache/apache.conf for further information.
APACHE_DOCKER_CFG="/omd/sites/$CMK_SITE_ID/etc/apache/conf.d/cmk_docker.conf"
echo -e "# Created for Checkmk docker container\\n\\nUseCanonicalName Off\\n" >"$APACHE_DOCKER_CFG"
chown "$CMK_SITE_ID:$CMK_SITE_ID" "$APACHE_DOCKER_CFG"
# Redirect top level requests to the sites base url
echo -e "# Redirect top level requests to the sites base url\\nRedirectMatch 302 ^/$ /$CMK_SITE_ID/\\n" >>"$APACHE_DOCKER_CFG"
}

if [ -z "$CMK_SITE_ID" ]; then
echo "ERROR: No site ID given"
exit 1
@@ -55,17 +69,7 @@ if [ ! -d "/opt/omd/sites/$CMK_SITE_ID/etc" ]; then
omd config "$CMK_SITE_ID" set APACHE_TCP_ADDR 0.0.0.0
omd config "$CMK_SITE_ID" set APACHE_TCP_PORT 5000

# We have the special situation that the site apache is directly accessed from
# external without a system apache reverse proxy. We need to disable the canonical
# name redirect here to make redirects work as expected.
#
# In a reverse proxy setup the proxy would rewrite the host to the host requested by the user.
# See omd/packages/apache-omd/skel/etc/apache/apache.conf for further information.
APACHE_DOCKER_CFG="/omd/sites/$CMK_SITE_ID/etc/apache/conf.d/cmk_docker.conf"
echo -e "# Created for Checkmk docker container\\n\\nUseCanonicalName Off\\n" >"$APACHE_DOCKER_CFG"
chown "$CMK_SITE_ID:$CMK_SITE_ID" "$APACHE_DOCKER_CFG"
# Redirect top level requests to the sites base url
echo -e "# Redirect top level requests to the sites base url\\nRedirectMatch 302 ^/$ /$CMK_SITE_ID/\\n" >>"$APACHE_DOCKER_CFG"
create_system_apache_config

if [ "$CMK_LIVESTATUS_TCP" = "on" ]; then
omd config "$CMK_SITE_ID" set LIVESTATUS_TCP on
@@ -95,6 +99,7 @@ fi
if [ ! -e "/omd/sites/$CMK_SITE_ID/version" ]; then
echo "### UPDATING SITE"
exec_hook pre-update
create_system_apache_config
omd -f update --conflict=install "$CMK_SITE_ID"
exec_hook post-update
fi

0 comments on commit 78d2811

Please sign in to comment.
You can’t perform that action at this time.