From 25e89f7bac0bb43fb7aeab7bb78de42e500f8c0d Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 23 Sep 2025 10:47:00 +0200 Subject: [PATCH] Refactor Caddyfile configuration for headscale-admin (#7821) --- ct/headscale.sh | 2 ++ install/headscale-install.sh | 28 +++++++++++++--------------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/ct/headscale.sh b/ct/headscale.sh index 4dd3de7f2..6aeb5d5ac 100644 --- a/ct/headscale.sh +++ b/ct/headscale.sh @@ -53,3 +53,5 @@ description msg_ok "Completed Successfully!\n" echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}" +echo -e "${INFO}${YW} Access it using the following URL:${CL}" +echo -e "${TAB}${GATEWAY}${BGN}Headscale API: ${IP}/api (no Frontend) | headscale-admin: http://${IP}/admin/${CL}" diff --git a/install/headscale-install.sh b/install/headscale-install.sh index 27a7431cc..770a83a9e 100644 --- a/install/headscale-install.sh +++ b/install/headscale-install.sh @@ -24,26 +24,24 @@ if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then $STD caddy stop rm /etc/caddy/Caddyfile cat <<'EOF' >/etc/caddy/Caddyfile -:{$PORT:80} +:80 + +redir /admin /admin/ handle_path /admin* { - root * /opt/headscale-admin - encode gzip zstd + root * /opt/headscale-admin + encode gzip zstd - # Correct MIME types for JS/WASM - header { - @js_files path *.js - @wasm_files path *.wasm + header { + X-Content-Type-Options nosniff + } - Content-Type @js_files application/javascript - Content-Type @wasm_files application/wasm + try_files {path} {path}/ /opt/headscale-admin/index.html + file_server +} - X-Content-Type-Options nosniff - } - - # Fallback for SPA routing - try_files {path} {path}/ index.html - file_server +handle /api/* { + reverse_proxy localhost:8080 } EOF