Skip to content

Commit

Permalink
Allow running under subpath while proxying
Browse files Browse the repository at this point in the history
  • Loading branch information
marvin-roesch committed Sep 24, 2020
1 parent 6cf6b0d commit 370fdf7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 7 additions & 0 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ The only option for the UI, is the URL(s) of your Connect cluster(s).

-e "CADDY_OPTIONS=basicauth / [USER] [PASS]"

- `RELATIVE_PROXY_URL=[true|false]`

When proxying Connect, enabling this option will set the Connect endpoint in the UI
as a relative URL. This can help when running
Kafka Connect UI under a subpath of your server (e.g
`http://url:8000/kc-ui` instead of `http://url:8000/`).

# Kafka Connect Configuration

If you don't wish to proxy Connect's REST api, you should permit CORS via setting
Expand Down
9 changes: 8 additions & 1 deletion docker/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PROXY="${PROXY:-true}"
PROXY_SKIP_VERIFY="${PROXY_SKIP_VERIFY:-false}"
INSECURE_PROXY=""
CADDY_OPTIONS="${CADDY_OPTIONS:-}"
RELATIVE_PROXY_URL="${RELATIVE_PROXY_URL:-false}"
PORT="${PORT:-8000}"

{
Expand Down Expand Up @@ -61,10 +62,16 @@ proxy /api/$CLUSTER_SANITIZED_NAME $CLUSTER_URL {
$INSECURE_PROXY
}
EOF
if echo "$RELATIVE_PROXY_URL" | egrep -sq "true|TRUE|y|Y|yes|YES|1"; then
CLUSTER_URL="api/$CLUSTER_SANITIZED_NAME"
else
CLUSTER_URL="/api/$CLUSTER_SANITIZED_NAME"
fi

cat <<EOF >>/tmp/env.js
$OPEN_CURL
NAME: "$CLUSTER_NAME",
KAFKA_CONNECT: "/api/$CLUSTER_SANITIZED_NAME"
KAFKA_CONNECT: "$CLUSTER_URL"
}
EOF
else
Expand Down

0 comments on commit 370fdf7

Please sign in to comment.