fix: recursively update explicit ports in imported Caddy configuration files
Main / build (push) Waiting to run

This commit is contained in:
2026-07-08 13:04:50 +08:00
parent f05e5e0410
commit c1dd5bf640
+11
View File
@@ -172,6 +172,11 @@ update_caddyfile_fallback() {
# Prepend a new global block at the very top of the Caddyfile
echo -e "{\n https_port 4443\n}\n$(cat $is_caddyfile)" >$is_caddyfile
fi
# 4. Replace any explicit :443 in other conf files inside /etc/caddy/sing-box/
if [[ -d /etc/caddy/sing-box ]]; then
sed -i 's/:443\b/:4443/g' /etc/caddy/sing-box/*.conf 2>/dev/null
fi
}
install_haproxy() {
@@ -197,6 +202,12 @@ restore_caddy_default() {
sed -i 's/:4443[[:space:]]*{/:443 {/g' $is_caddyfile
sed -i 's/https_port 4443/https_port 443/g' $is_caddyfile
fi
# Restore explicit :4443 in other conf files inside /etc/caddy/sing-box/
if [[ -d /etc/caddy/sing-box ]]; then
sed -i 's/:4443\b/:443/g' /etc/caddy/sing-box/*.conf 2>/dev/null
fi
systemctl restart caddy >/dev/null 2>&1
}