feat: ship default catch-all site on fresh apt install

Fresh apt installs now drop a catch-all server block at `/etc/nginx/conf.d/00-default-vhost.conf` that uses `ssl_reject_handshake on` and `return 444` to drop requests with unknown Host headers. Conflicting upstream nginx default vhosts are renamed to `*.dokku-disabled` rather than deleted, preserving any local edits. The new `dokku/install_default_site` debconf flag opts out of the install. Upgrades leave existing nginx config untouched.
This commit is contained in:
Jose Diaz-Gonzalez
2026-04-27 02:55:40 -04:00
parent a4f26a356a
commit d7c88ae298
7 changed files with 246 additions and 32 deletions

1
debian/config vendored
View File

@@ -14,5 +14,6 @@ db_input "high" "dokku/hostname" || true
db_input "high" "dokku/vhost_enable" || true
if [ "$ACTION" != "reconfigure" ]; then
db_input "high" "dokku/key_file" || true
db_input "high" "dokku/install_default_site" || true
fi
db_go || true

35
debian/postinst vendored
View File

@@ -135,6 +135,38 @@ setup-sshcommand() {
fi
}
setup-default-site() {
db_get "dokku/install_default_site"
if [ "$RET" != "true" ]; then
return
fi
local default_vhost_target="/etc/nginx/conf.d/00-default-vhost.conf"
local default_vhost_source="${DOKKU_LIB_ROOT}/core-plugins/available/nginx-vhosts/templates/default-site.conf"
if [ -e "$default_vhost_target" ]; then
return
fi
if [ ! -f "$default_vhost_source" ]; then
return
fi
for path in /etc/nginx/sites-enabled/default /etc/nginx/sites-available/default /etc/nginx/conf.d/default.conf; do
if [ -e "$path" ] && [ ! -e "${path}.dokku-disabled" ]; then
mv -n "$path" "${path}.dokku-disabled"
echo "Disabled $path (renamed to ${path}.dokku-disabled)" 1>&2
fi
done
echo "Installing nginx default catch-all site at $default_vhost_target"
install -m 0644 -o root -g root "$default_vhost_source" "$default_vhost_target"
if command -v dokku &>/dev/null; then
dokku nginx:reload || true
fi
}
dpkg-handling() {
if [ -f "${DOKKU_ROOT}/VHOST" ]; then
echo "VHOST file detected, skipping modification"
@@ -170,6 +202,9 @@ case "$1" in
setup-plugins
setup-sshcommand
setup-docker-live-restore
if [ -z "$2" ]; then
setup-default-site
fi
;;
*)

5
debian/templates vendored
View File

@@ -22,3 +22,8 @@ Template: dokku/nginx_enable
Description: Enable nginx-vhosts plugin?
Type: boolean
Default: true
Template: dokku/install_default_site
Description: Install a catch-all nginx default site on fresh install?
Type: boolean
Default: true