feat(server): fall back Sentinel URL to request host

Use the current request scheme/host when no FQDN or public IP is set,
skipping loopback hosts. Polish boarding/server create cards, optional
listbox tooltips, and cover the layout and Sentinel URL behavior in tests.
This commit is contained in:
Andras Bacsai
2026-08-07 15:41:39 +02:00
parent 28f57aafb8
commit de4e74b4cd
14 changed files with 203 additions and 89 deletions
+26 -1
View File
@@ -228,7 +228,7 @@ class ServerSetting extends Model
}
if (blank($url)) {
throw new \RuntimeException('Set an instance FQDN or public IP before enabling Sentinel.');
throw new \RuntimeException('Set an instance FQDN, public IP, or reachable Coolify URL before enabling Sentinel.');
}
return $url;
@@ -246,6 +246,8 @@ class ServerSetting extends Model
$domain = 'http://'.$settings->public_ipv4.':8000';
} elseif ($settings->public_ipv6) {
$domain = 'http://'.$settings->public_ipv6.':8000';
} else {
$domain = $this->sentinelUrlFromCurrentRequest();
}
$this->sentinel_custom_url = $domain;
if ($save) {
@@ -259,6 +261,29 @@ class ServerSetting extends Model
return $domain;
}
private function sentinelUrlFromCurrentRequest(): ?string
{
if (! app()->bound('request')) {
return null;
}
$request = request();
$host = strtolower($request->getHost());
if (
$host === 'localhost' ||
str_ends_with($host, '.localhost') ||
$host === '::1' ||
$host === '::' ||
$host === '0.0.0.0' ||
str_starts_with($host, '127.')
) {
return null;
}
return $request->getSchemeAndHttpHost();
}
public function server()
{
return $this->belongsTo(Server::class);