fix: respect server fqdn
This commit is contained in:
parent
79fde593a9
commit
3d43f2127a
@ -22,9 +22,6 @@ class General extends Component
|
|||||||
public string $git_branch;
|
public string $git_branch;
|
||||||
public string|null $git_commit_sha;
|
public string|null $git_commit_sha;
|
||||||
public string $build_pack;
|
public string $build_pack;
|
||||||
public string|null $wildcard_domain = null;
|
|
||||||
public string|null $server_wildcard_domain = null;
|
|
||||||
public string|null $global_wildcard_domain = null;
|
|
||||||
|
|
||||||
public bool $is_static;
|
public bool $is_static;
|
||||||
public bool $is_git_submodules_enabled;
|
public bool $is_git_submodules_enabled;
|
||||||
@ -91,18 +88,20 @@ class General extends Component
|
|||||||
$this->application->settings->save();
|
$this->application->settings->save();
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
$this->application->refresh();
|
$this->application->refresh();
|
||||||
$this->checkWildCardDomain();
|
|
||||||
$this->emit('success', 'Application settings updated!');
|
$this->emit('success', 'Application settings updated!');
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function checkWildCardDomain()
|
public function getWildcardDomain() {
|
||||||
{
|
$server = data_get($this->application, 'destination.server');
|
||||||
$coolify_instance_settings = InstanceSettings::get();
|
if ($server) {
|
||||||
$this->server_wildcard_domain = data_get($this->application, 'destination.server.settings.wildcard_domain');
|
$fqdn = generateFqdn($server, $this->application->uuid);
|
||||||
$this->global_wildcard_domain = data_get($coolify_instance_settings, 'wildcard_domain');
|
ray($fqdn);
|
||||||
$this->wildcard_domain = $this->server_wildcard_domain ?? $this->global_wildcard_domain ?? null;
|
$this->application->fqdn = $fqdn;
|
||||||
}
|
$this->application->save();
|
||||||
|
$this->emit('success', 'Application settings updated!');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
public function mount()
|
public function mount()
|
||||||
{
|
{
|
||||||
$this->is_static = $this->application->settings->is_static;
|
$this->is_static = $this->application->settings->is_static;
|
||||||
@ -112,31 +111,6 @@ class General extends Component
|
|||||||
$this->is_preview_deployments_enabled = $this->application->settings->is_preview_deployments_enabled;
|
$this->is_preview_deployments_enabled = $this->application->settings->is_preview_deployments_enabled;
|
||||||
$this->is_auto_deploy_enabled = $this->application->settings->is_auto_deploy_enabled;
|
$this->is_auto_deploy_enabled = $this->application->settings->is_auto_deploy_enabled;
|
||||||
$this->is_force_https_enabled = $this->application->settings->is_force_https_enabled;
|
$this->is_force_https_enabled = $this->application->settings->is_force_https_enabled;
|
||||||
$this->checkWildCardDomain();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateGlobalRandomDomain()
|
|
||||||
{
|
|
||||||
// Set wildcard domain based on Global wildcard domain
|
|
||||||
$url = Url::fromString($this->global_wildcard_domain);
|
|
||||||
$host = $url->getHost();
|
|
||||||
$path = $url->getPath() === '/' ? '' : $url->getPath();
|
|
||||||
$scheme = $url->getScheme();
|
|
||||||
$this->application->fqdn = $scheme . '://' . $this->application->uuid . '.' . $host . $path;
|
|
||||||
$this->application->save();
|
|
||||||
$this->emit('success', 'Application settings updated!');
|
|
||||||
}
|
|
||||||
|
|
||||||
public function generateServerRandomDomain()
|
|
||||||
{
|
|
||||||
// Set wildcard domain based on Server wildcard domain
|
|
||||||
$url = Url::fromString($this->server_wildcard_domain);
|
|
||||||
$host = $url->getHost();
|
|
||||||
$path = $url->getPath() === '/' ? '' : $url->getPath();
|
|
||||||
$scheme = $url->getScheme();
|
|
||||||
$this->application->fqdn = $scheme . '://' . $this->application->uuid . '.' . $host . $path;
|
|
||||||
$this->application->save();
|
|
||||||
$this->emit('success', 'Application settings updated!');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function submit()
|
public function submit()
|
||||||
|
@ -11,6 +11,7 @@ use App\Traits\SaveFromRedirect;
|
|||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Spatie\Url\Url;
|
||||||
|
|
||||||
class GithubPrivateRepository extends Component
|
class GithubPrivateRepository extends Component
|
||||||
{
|
{
|
||||||
@ -144,8 +145,9 @@ class GithubPrivateRepository extends Component
|
|||||||
$application->settings->is_static = $this->is_static;
|
$application->settings->is_static = $this->is_static;
|
||||||
$application->settings->save();
|
$application->settings->save();
|
||||||
|
|
||||||
$sslip = sslip($destination->server);
|
$fqdn = generateFqdn($destination->server, $application->uuid);
|
||||||
$application->fqdn = "http://{$application->uuid}.$sslip";
|
$application->fqdn = $fqdn;
|
||||||
|
|
||||||
$application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid);
|
$application->name = generate_application_name($this->selected_repository_owner . '/' . $this->selected_repository_repo, $this->selected_branch_name, $application->uuid);
|
||||||
$application->save();
|
$application->save();
|
||||||
|
|
||||||
|
@ -112,8 +112,8 @@ class GithubPrivateRepositoryDeployKey extends Component
|
|||||||
$application->settings->is_static = $this->is_static;
|
$application->settings->is_static = $this->is_static;
|
||||||
$application->settings->save();
|
$application->settings->save();
|
||||||
|
|
||||||
$sslip = sslip($destination->server);
|
$fqdn = generateFqdn($destination->server, $application->uuid);
|
||||||
$application->fqdn = "http://{$application->uuid}.$sslip";
|
$application->fqdn = $fqdn;
|
||||||
$application->name = generate_random_name($application->uuid);
|
$application->name = generate_random_name($application->uuid);
|
||||||
$application->save();
|
$application->save();
|
||||||
|
|
||||||
|
@ -156,8 +156,8 @@ class PublicGitRepository extends Component
|
|||||||
$application->settings->is_static = $this->is_static;
|
$application->settings->is_static = $this->is_static;
|
||||||
$application->settings->save();
|
$application->settings->save();
|
||||||
|
|
||||||
$sslip = sslip($destination->server);
|
$fqdn = generateFqdn($destination->server, $application->uuid);
|
||||||
$application->fqdn = "http://{$application->uuid}.$sslip";
|
$application->fqdn = $fqdn;
|
||||||
$application->name = generate_application_name($this->git_repository, $this->git_branch, $application->uuid);
|
$application->name = generate_application_name($this->git_repository, $this->git_branch, $application->uuid);
|
||||||
$application->save();
|
$application->save();
|
||||||
|
|
||||||
|
@ -60,10 +60,10 @@ CMD ["nginx", "-g", "daemon off;"]
|
|||||||
'source_type' => GithubApp::class
|
'source_type' => GithubApp::class
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$sslip = sslip($destination->server);
|
$fqdn = generateFqdn($destination->server, $application->uuid);
|
||||||
$application->update([
|
$application->update([
|
||||||
'name' => 'dockerfile-' . $application->uuid,
|
'name' => 'dockerfile-' . $application->uuid,
|
||||||
'fqdn' => "http://{$application->uuid}.$sslip"
|
'fqdn' => $fqdn
|
||||||
]);
|
]);
|
||||||
|
|
||||||
redirect()->route('project.application.configuration', [
|
redirect()->route('project.application.configuration', [
|
||||||
|
@ -350,8 +350,7 @@ class Service extends BaseModel
|
|||||||
}
|
}
|
||||||
if ($key->startsWith('SERVICE_FQDN')) {
|
if ($key->startsWith('SERVICE_FQDN')) {
|
||||||
if (is_null(data_get($savedService, 'fqdn'))) {
|
if (is_null(data_get($savedService, 'fqdn'))) {
|
||||||
$sslip = sslip($this->server);
|
$fqdn = generateFqdn($this->server, $containerName);
|
||||||
$fqdn = "http://$containerName.$sslip";
|
|
||||||
if (substr_count($key->value(), '_') === 2 && $key->contains("=")) {
|
if (substr_count($key->value(), '_') === 2 && $key->contains("=")) {
|
||||||
$path = $value->value();
|
$path = $value->value();
|
||||||
if ($generatedServiceFQDNS->count() > 0) {
|
if ($generatedServiceFQDNS->count() > 0) {
|
||||||
@ -364,7 +363,7 @@ class Service extends BaseModel
|
|||||||
} else {
|
} else {
|
||||||
$generatedServiceFQDNS->put($key->value(), $fqdn);
|
$generatedServiceFQDNS->put($key->value(), $fqdn);
|
||||||
}
|
}
|
||||||
$fqdn = "http://$containerName.$sslip$path";
|
$fqdn = "$fqdn$path";
|
||||||
}
|
}
|
||||||
if (!$isDatabase) {
|
if (!$isDatabase) {
|
||||||
$savedService->fqdn = $fqdn;
|
$savedService->fqdn = $fqdn;
|
||||||
@ -385,8 +384,7 @@ class Service extends BaseModel
|
|||||||
$forService = $value->afterLast('_');
|
$forService = $value->afterLast('_');
|
||||||
$generatedValue = null;
|
$generatedValue = null;
|
||||||
if ($command->value() === 'FQDN' || $command->value() === 'URL') {
|
if ($command->value() === 'FQDN' || $command->value() === 'URL') {
|
||||||
$sslip = sslip($this->server);
|
$fqdn = generateFqdn($this->server, $containerName);
|
||||||
$fqdn = "http://$containerName.$sslip";
|
|
||||||
if ($foundEnv) {
|
if ($foundEnv) {
|
||||||
$fqdn = data_get($foundEnv, 'value');
|
$fqdn = data_get($foundEnv, 'value');
|
||||||
} else {
|
} else {
|
||||||
|
@ -395,16 +395,29 @@ function data_get_str($data, $key, $default = null): Stringable
|
|||||||
return Str::of($str);
|
return Str::of($str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateFqdn(Server $server, string $random)
|
||||||
|
{
|
||||||
|
$wildcard = data_get($server, 'settings.wildcard_domain');
|
||||||
|
if (is_null($wildcard) || $wildcard === '') {
|
||||||
|
$wildcard = sslip($server);
|
||||||
|
}
|
||||||
|
$url = Url::fromString($wildcard);
|
||||||
|
$host = $url->getHost();
|
||||||
|
$path = $url->getPath() === '/' ? '' : $url->getPath();
|
||||||
|
$scheme = $url->getScheme();
|
||||||
|
$finalFqdn = "$scheme://{$random}.$host$path" ;
|
||||||
|
return $finalFqdn;
|
||||||
|
}
|
||||||
function sslip(Server $server)
|
function sslip(Server $server)
|
||||||
{
|
{
|
||||||
if (isDev()) {
|
if (isDev()) {
|
||||||
return "127.0.0.1.sslip.io";
|
return "http://127.0.0.1.sslip.io";
|
||||||
}
|
}
|
||||||
if ($server->ip === 'host.docker.internal') {
|
if ($server->ip === 'host.docker.internal') {
|
||||||
$baseIp = base_ip();
|
$baseIp = base_ip();
|
||||||
return "$baseIp.sslip.io";
|
return "http://$baseIp.sslip.io";
|
||||||
}
|
}
|
||||||
return "{$server->ip}.sslip.io";
|
return "http://{$server->ip}.sslip.io";
|
||||||
}
|
}
|
||||||
|
|
||||||
function getServiceTemplates()
|
function getServiceTemplates()
|
||||||
|
@ -15,16 +15,8 @@
|
|||||||
<div class="flex items-end gap-2">
|
<div class="flex items-end gap-2">
|
||||||
<x-forms.input placeholder="https://coolify.io" id="application.fqdn" label="Domains"
|
<x-forms.input placeholder="https://coolify.io" id="application.fqdn" label="Domains"
|
||||||
helper="You can specify one domain with path or more with comma. You can specify a port to bind the domain to.<br><br><span class='text-helper'>Example</span><br>- http://app.coolify.io, https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3<br>- http://app.coolify.io:3000 -> app.coolify.io will point to port 3000 inside the container. " />
|
helper="You can specify one domain with path or more with comma. You can specify a port to bind the domain to.<br><br><span class='text-helper'>Example</span><br>- http://app.coolify.io, https://cloud.coolify.io/dashboard<br>- http://app.coolify.io/api/v3<br>- http://app.coolify.io:3000 -> app.coolify.io will point to port 3000 inside the container. " />
|
||||||
@if ($wildcard_domain)
|
<x-forms.button wire:click="getWildcardDomain">Generate Domain
|
||||||
@if ($global_wildcard_domain)
|
</x-forms.button>
|
||||||
<x-forms.button wire:click="generateGlobalRandomDomain">Set Global Wildcard
|
|
||||||
</x-forms.button>
|
|
||||||
@endif
|
|
||||||
@if ($server_wildcard_domain)
|
|
||||||
<x-forms.button wire:click="generateServerRandomDomain">Set Server Wildcard
|
|
||||||
</x-forms.button>
|
|
||||||
@endif
|
|
||||||
@endif
|
|
||||||
</div>
|
</div>
|
||||||
@if (!$application->dockerfile)
|
@if (!$application->dockerfile)
|
||||||
<div class="flex items-end gap-2">
|
<div class="flex items-end gap-2">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user