fix: make Caddyfile global config update robust to avoid IPv6 conflicts
Main / build (push) Waiting to run
Main / build (push) Waiting to run
This commit is contained in:
+8
-5
@@ -159,15 +159,18 @@ update_caddyfile_fallback() {
|
||||
sed -i 's/servers :443/servers :4443/g' $is_caddyfile
|
||||
|
||||
# 2. Replace any site block headers explicit :443 with :4443
|
||||
sed -i 's/:443[[:space:]]*{/:4443 {/g' $is_caddyfile
|
||||
sed -i 's/:443\b/:4443/g' $is_caddyfile
|
||||
|
||||
# 3. Add or update https_port 4443 in global block
|
||||
if [[ $(grep "https_port" $is_caddyfile) ]]; then
|
||||
# 3. Add or update https_port 4443 globally
|
||||
if grep -q "https_port" $is_caddyfile; then
|
||||
# Replace existing https_port with 4443
|
||||
sed -i 's/https_port[[:space:]]\+[0-9]\+/https_port 4443/g' $is_caddyfile
|
||||
else
|
||||
# Find first { and insert https_port 4443 on the next line
|
||||
elif grep -q '^[[:space:]]*{[[:space:]]*$' $is_caddyfile; then
|
||||
# Insert inside existing global block
|
||||
sed -i '0,/^[[:space:]]*{[[:space:]]*$/s//{\n https_port 4443/' $is_caddyfile
|
||||
else
|
||||
# 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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user