mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(sentinel): push local Sentinel to coolify:8080 for any host gateway URL
Closes #12171
This commit is contained in:
@@ -319,7 +319,9 @@ class ServerSetting extends Model
|
||||
{
|
||||
$url = $this->sentinel_custom_url;
|
||||
|
||||
if ($this->server->isLocalhost() && $url === 'http://host.docker.internal:8000') {
|
||||
// The local Sentinel runs on the coolify network. A host gateway URL leaves that network
|
||||
// through the host INPUT chain, where host firewalls such as UFW drop it.
|
||||
if ($this->server->isLocalhost() && strtolower((string) parse_url((string) $url, PHP_URL_HOST)) === 'host.docker.internal') {
|
||||
$url = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -193,6 +193,30 @@ describe('ServerSetting::ensureSentinelUrl', function () {
|
||||
->and($this->server->settings->fresh()->sentinel_custom_url)->toBe($url);
|
||||
});
|
||||
|
||||
it('replaces a local host gateway endpoint on any port, because the Coolify network firewall can block it', function (string $legacyUrl) {
|
||||
$this->server->update(['ip' => 'host.docker.internal']);
|
||||
DB::table('server_settings')->where('id', $this->server->settings->id)->update([
|
||||
'sentinel_custom_url' => $legacyUrl,
|
||||
]);
|
||||
|
||||
$url = $this->server->settings->fresh()->ensureSentinelUrl();
|
||||
|
||||
expect($url)->toBe('http://coolify:8080')
|
||||
->and($this->server->settings->fresh()->sentinel_custom_url)->toBe($url);
|
||||
})->with([
|
||||
'custom APP_PORT' => 'http://host.docker.internal:8010',
|
||||
'trailing slash' => 'http://host.docker.internal:8000/',
|
||||
'uppercase host' => 'HTTP://Host.Docker.Internal:8010',
|
||||
]);
|
||||
|
||||
it('keeps a host gateway endpoint for a remote server', function () {
|
||||
DB::table('server_settings')->where('id', $this->server->settings->id)->update([
|
||||
'sentinel_custom_url' => 'http://host.docker.internal:8010',
|
||||
]);
|
||||
|
||||
expect($this->server->settings->fresh()->ensureSentinelUrl())->toBe('http://host.docker.internal:8010');
|
||||
});
|
||||
|
||||
it('preserves an explicit custom URL for the local server', function () {
|
||||
$this->server->update(['ip' => 'host.docker.internal']);
|
||||
DB::table('server_settings')->where('id', $this->server->settings->id)->update([
|
||||
|
||||
Reference in New Issue
Block a user