Refactor Caddyfile configuration for headscale-admin (#7821)

This commit is contained in:
CanbiZ 2025-09-23 10:47:00 +02:00 committed by GitHub
parent 2686753448
commit 25e89f7bac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 15 deletions

View File

@ -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}"

View File

@ -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