multiple domains
This commit is contained in:
parent
38a45d9816
commit
b14612aba5
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
use App\Models\Application;
|
use App\Models\Application;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
|
use Illuminate\Support\Str;
|
||||||
|
|
||||||
class General extends Component
|
class General extends Component
|
||||||
{
|
{
|
||||||
@ -75,6 +76,10 @@ public function submit()
|
|||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->validate();
|
$this->validate();
|
||||||
|
$domains = Str::of($this->application->fqdn)->trim()->explode(',')->map(function ($domain) {
|
||||||
|
return Str::of($domain)->trim()->lower();
|
||||||
|
});
|
||||||
|
$this->application->fqdn = $domains->implode(',');
|
||||||
$this->application->save();
|
$this->application->save();
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return generalErrorHandler($e, $this);
|
return generalErrorHandler($e, $this);
|
||||||
|
@ -378,16 +378,21 @@ private function set_labels_for_applications()
|
|||||||
$labels[] = 'coolify.type=application';
|
$labels[] = 'coolify.type=application';
|
||||||
$labels[] = 'coolify.name=' . $this->application->name;
|
$labels[] = 'coolify.name=' . $this->application->name;
|
||||||
if ($this->application->fqdn) {
|
if ($this->application->fqdn) {
|
||||||
$url = Url::fromString($this->application->fqdn);
|
$domains = Str::of($this->application->fqdn)->explode(',');
|
||||||
|
$labels[] = 'traefik.enable=true';
|
||||||
|
foreach ($domains as $domain) {
|
||||||
|
$url = Url::fromString($domain);
|
||||||
$host = $url->getHost();
|
$host = $url->getHost();
|
||||||
$path = $url->getPath();
|
$path = $url->getPath();
|
||||||
$labels[] = 'traefik.enable=true';
|
$slug = Str::slug($url);
|
||||||
|
$label_id = "{$this->application->uuid}-{$slug}";
|
||||||
if ($path === '/') {
|
if ($path === '/') {
|
||||||
$labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && Path(`{$path}`)";
|
$labels[] = "traefik.http.routers.{$label_id}.rule=Host(`{$host}`) && Path(`{$path}`)";
|
||||||
} else {
|
} else {
|
||||||
$labels[] = "traefik.http.routers.{$this->application->uuid}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
$labels[] = "traefik.http.routers.{$label_id}.rule=Host(`{$host}`) && PathPrefix(`{$path}`)";
|
||||||
$labels[] = "traefik.http.routers.{$this->application->uuid}.middlewares={$this->application->uuid}-stripprefix";
|
$labels[] = "traefik.http.routers.{$label_id}.middlewares={$label_id}-stripprefix";
|
||||||
$labels[] = "traefik.http.middlewares.{$this->application->uuid}-stripprefix.stripprefix.prefixes={$path}";
|
$labels[] = "traefik.http.middlewares.{$label_id}-stripprefix.stripprefix.prefixes={$path}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $labels;
|
return $labels;
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
Delete</x-inputs.button>
|
Delete</x-inputs.button>
|
||||||
<span wire:poll.5000ms='pollingStatus'>
|
<span wire:poll.5000ms='pollingStatus'>
|
||||||
@if ($application->status === 'running')
|
@if ($application->status === 'running')
|
||||||
@if (data_get($application, 'fqdn'))
|
|
||||||
<a target="_blank" href="{{ data_get($application, 'fqdn') }}">Open URL</a>
|
|
||||||
@endif
|
|
||||||
|
|
||||||
@if (data_get($application, 'ports_mappings_array'))
|
@if (data_get($application, 'ports_mappings_array'))
|
||||||
@foreach ($application->ports_mappings_array as $port)
|
@foreach ($application->ports_mappings_array as $port)
|
||||||
@if (config('app.env') === 'local')
|
@if (config('app.env') === 'local')
|
||||||
|
Loading…
Reference in New Issue
Block a user