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:
7 files changed
+246
-32
No files matched your search
Vendored
+35
@@ -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
|
||||
;;
|
||||
|
||||
*)
|
||||
|
||||
Reference in new issue
Block a user