From e25f3dce5254889afa6c6018e50c81f700cefa90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Slavi=C5=A1a=20Are=C5=BEina?= <58952836+tremor021@users.noreply.github.com> Date: Thu, 24 Jul 2025 21:00:13 +0200 Subject: [PATCH] Headscale: Add headscale-admin UI as option (#6205) --- ct/headscale.sh | 1 + frontend/public/json/headscale.json | 4 ++++ install/headscale-install.sh | 37 +++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/ct/headscale.sh b/ct/headscale.sh index 7ec236fa0..4e802836f 100644 --- a/ct/headscale.sh +++ b/ct/headscale.sh @@ -38,6 +38,7 @@ function update_script() { msg_ok "Stopped ${APP}" fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" + fetch_and_deploy_gh_release "headscale-admin" "GoodiesHQ/headscale-admin" "prebuild" "latest" "/opt/headscale-admin" "admin.zip" msg_info "Starting ${APP}" # Temporary fix until headscale project resolves service getting disabled on updates. diff --git a/frontend/public/json/headscale.json b/frontend/public/json/headscale.json index 323edb61b..4bca10f86 100644 --- a/frontend/public/json/headscale.json +++ b/frontend/public/json/headscale.json @@ -35,6 +35,10 @@ { "text": "Configuration settings: `/etc/headscale/config.yaml`", "type": "info" + }, + { + "text": "Access headscale-admin UI via `http:///admin/`", + "type": "info" } ] } diff --git a/install/headscale-install.sh b/install/headscale-install.sh index cf28206ad..38ccc7e9e 100644 --- a/install/headscale-install.sh +++ b/install/headscale-install.sh @@ -15,6 +15,43 @@ update_os fetch_and_deploy_gh_release "headscale" "juanfont/headscale" "binary" +read -r -p "${TAB3}Would you like to add headscale-admin UI? " prompt +if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then + fetch_and_deploy_gh_release "headscale-admin" "GoodiesHQ/headscale-admin" "prebuild" "latest" "/opt/headscale-admin" "admin.zip" + + msg_info "Configuring headscale-admin" + $STD apt-get install -y caddy + $STD caddy stop + rm /etc/caddy/Caddyfile + cat </etc/caddy/Caddyfile +:{$PORT:80} + +handle_path /admin* { + root * /opt/headscale-admin + encode gzip zstd + + # Correct MIME types for JS/WASM + header { + @js_files path *.js + @wasm_files path *.wasm + + Content-Type @js_files application/javascript + Content-Type @wasm_files application/wasm + + X-Content-Type-Options nosniff + } + + # Fallback for SPA routing + try_files {path} {path}/ index.html + file_server +} + +EOF + caddy fmt --overwrite /etc/caddy/Caddyfile + systemctl start caddy + msg_ok "Configured headscale-admin" +fi + msg_info "Starting service" systemctl enable -q --now headscale msg_ok "Service started"