Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

fix(install): nginx refused to start on any install that set PANEL_DOMAIN

Juan Denis767c840ae925
diff --git a/install.sh b/install.sh
index 27010afa..ed590ddf 100644
--- a/install.sh
+++ b/install.sh
@@ -1313,12 +1313,21 @@ EOF
cat > /etc/nginx/serverkit-conf.d/canonical-domain.conf <<EOF
# Auto-generated by ServerKit install.sh
# Redirect direct IP access to the canonical panel domain.
+#
+# NOT \`listen 80 default_server\` with \`server_name _\`. Both serverkit.conf and
+# serverkit-insecure.conf already declare a default server on :80 and then
+# include this directory, and a second default server for the same address:port
+# is a FATAL nginx error — "a duplicate default server for 0.0.0.0:80" — so
+# nginx refused to start on any install that set PANEL_DOMAIN.
+#
+# A regex server_name is the right tool anyway: nginx tries exact names, then
+# wildcards, then regexes, and only then the default server, so this block wins
+# for a bare-IP Host and every other Host still falls through to the panel.
+# That also removes the \`if\`, which nginx documents as best avoided.
server {
- listen 80 default_server;
- server_name _;
- if (\$host ~* ^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$) {
- return 301 ${url_scheme}://$PANEL_DOMAIN\$request_uri;
- }
+ listen 80;
+ server_name ~^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\$;
+ return 301 ${url_scheme}://$PANEL_DOMAIN\$request_uri;
}
EOF
good "Canonical-domain redirect configured for $PANEL_DOMAIN"