mirror of
https://github.com/cupcakearmy/coolify.git
synced 2024-10-22 08:04:19 +02:00
refactor: Update ProxyTypes enum values to use TRAEFIK instead of TRAEFIK_V2
This commit is contained in:
parent
13e8d3c17c
commit
59702c6dbc
@ -5,7 +5,7 @@
|
|||||||
enum ProxyTypes: string
|
enum ProxyTypes: string
|
||||||
{
|
{
|
||||||
case NONE = 'NONE';
|
case NONE = 'NONE';
|
||||||
case TRAEFIK_V2 = 'TRAEFIK_V2';
|
case TRAEFIK = 'TRAEFIK';
|
||||||
case NGINX = 'NGINX';
|
case NGINX = 'NGINX';
|
||||||
case CADDY = 'CADDY';
|
case CADDY = 'CADDY';
|
||||||
}
|
}
|
||||||
|
@ -525,7 +525,7 @@ public function create_server(Request $request)
|
|||||||
'private_key_id' => $privateKey->id,
|
'private_key_id' => $privateKey->id,
|
||||||
'team_id' => $teamId,
|
'team_id' => $teamId,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
'type' => ProxyTypes::TRAEFIK_V2->value,
|
'type' => ProxyTypes::TRAEFIK->value,
|
||||||
'status' => ProxyStatus::EXITED->value,
|
'status' => ProxyStatus::EXITED->value,
|
||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
@ -179,7 +179,7 @@ public function selectExistingServer()
|
|||||||
public function getProxyType()
|
public function getProxyType()
|
||||||
{
|
{
|
||||||
// Set Default Proxy Type
|
// Set Default Proxy Type
|
||||||
$this->selectProxy(ProxyTypes::TRAEFIK_V2->value);
|
$this->selectProxy(ProxyTypes::TRAEFIK->value);
|
||||||
// $proxyTypeSet = $this->createdServer->proxy->type;
|
// $proxyTypeSet = $this->createdServer->proxy->type;
|
||||||
// if (!$proxyTypeSet) {
|
// if (!$proxyTypeSet) {
|
||||||
// $this->currentState = 'select-proxy';
|
// $this->currentState = 'select-proxy';
|
||||||
|
@ -104,7 +104,7 @@ public function submit()
|
|||||||
'private_key_id' => $this->private_key_id,
|
'private_key_id' => $this->private_key_id,
|
||||||
'proxy' => [
|
'proxy' => [
|
||||||
// set default proxy type to traefik v2
|
// set default proxy type to traefik v2
|
||||||
'type' => ProxyTypes::TRAEFIK_V2->value,
|
'type' => ProxyTypes::TRAEFIK->value,
|
||||||
'status' => ProxyStatus::EXITED->value,
|
'status' => ProxyStatus::EXITED->value,
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace App\Livewire\Server\Proxy;
|
namespace App\Livewire\Server\Proxy;
|
||||||
|
|
||||||
|
use App\Enums\ProxyTypes;
|
||||||
use App\Models\Server;
|
use App\Models\Server;
|
||||||
use Livewire\Component;
|
use Livewire\Component;
|
||||||
use Symfony\Component\Yaml\Yaml;
|
use Symfony\Component\Yaml\Yaml;
|
||||||
@ -45,7 +46,7 @@ public function addDynamicConfiguration()
|
|||||||
return redirect()->route('server.index');
|
return redirect()->route('server.index');
|
||||||
}
|
}
|
||||||
$proxy_type = $this->server->proxyType();
|
$proxy_type = $this->server->proxyType();
|
||||||
if ($proxy_type === 'TRAEFIK_V2') {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
if (! str($this->fileName)->endsWith('.yaml') && ! str($this->fileName)->endsWith('.yml')) {
|
if (! str($this->fileName)->endsWith('.yaml') && ! str($this->fileName)->endsWith('.yml')) {
|
||||||
$this->fileName = "{$this->fileName}.yaml";
|
$this->fileName = "{$this->fileName}.yaml";
|
||||||
}
|
}
|
||||||
@ -69,7 +70,7 @@ public function addDynamicConfiguration()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($proxy_type === 'TRAEFIK_V2') {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
$yaml = Yaml::parse($this->value);
|
$yaml = Yaml::parse($this->value);
|
||||||
$yaml = Yaml::dump($yaml, 10, 2);
|
$yaml = Yaml::dump($yaml, 10, 2);
|
||||||
$this->value = $yaml;
|
$this->value = $yaml;
|
||||||
|
@ -151,7 +151,7 @@ public function setupDefault404Redirect()
|
|||||||
$dynamic_conf_path = $this->proxyPath().'/dynamic';
|
$dynamic_conf_path = $this->proxyPath().'/dynamic';
|
||||||
$proxy_type = $this->proxyType();
|
$proxy_type = $this->proxyType();
|
||||||
$redirect_url = $this->proxy->redirect_url;
|
$redirect_url = $this->proxy->redirect_url;
|
||||||
if ($proxy_type === 'TRAEFIK_V2') {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
|
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.yaml";
|
||||||
} elseif ($proxy_type === 'CADDY') {
|
} elseif ($proxy_type === 'CADDY') {
|
||||||
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
|
$default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
|
||||||
@ -181,7 +181,7 @@ public function setupDefault404Redirect()
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($proxy_type === 'TRAEFIK_V2') {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
$dynamic_conf = [
|
$dynamic_conf = [
|
||||||
'http' => [
|
'http' => [
|
||||||
'routers' => [
|
'routers' => [
|
||||||
@ -255,7 +255,7 @@ public function setupDynamicProxyConfiguration()
|
|||||||
{
|
{
|
||||||
$settings = \App\Models\InstanceSettings::get();
|
$settings = \App\Models\InstanceSettings::get();
|
||||||
$dynamic_config_path = $this->proxyPath().'/dynamic';
|
$dynamic_config_path = $this->proxyPath().'/dynamic';
|
||||||
if ($this->proxyType() === 'TRAEFIK_V2') {
|
if ($this->proxyType() === ProxyTypes::TRAEFIK->value) {
|
||||||
$file = "$dynamic_config_path/coolify.yaml";
|
$file = "$dynamic_config_path/coolify.yaml";
|
||||||
if (empty($settings->fqdn) || (isCloud() && $this->id !== 0) || ! $this->isLocalhost()) {
|
if (empty($settings->fqdn) || (isCloud() && $this->id !== 0) || ! $this->isLocalhost()) {
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
@ -403,7 +403,7 @@ public function proxyPath()
|
|||||||
// TODO: should use /traefik for already exisiting configurations?
|
// TODO: should use /traefik for already exisiting configurations?
|
||||||
// Should move everything except /caddy and /nginx to /traefik
|
// Should move everything except /caddy and /nginx to /traefik
|
||||||
// The code needs to be modified as well, so maybe it does not worth it
|
// The code needs to be modified as well, so maybe it does not worth it
|
||||||
if ($proxyType === ProxyTypes::TRAEFIK_V2->value) {
|
if ($proxyType === ProxyTypes::TRAEFIK->value) {
|
||||||
$proxy_path = $proxy_path;
|
$proxy_path = $proxy_path;
|
||||||
} elseif ($proxyType === ProxyTypes::CADDY->value) {
|
} elseif ($proxyType === ProxyTypes::CADDY->value) {
|
||||||
$proxy_path = $proxy_path.'/caddy';
|
$proxy_path = $proxy_path.'/caddy';
|
||||||
@ -421,7 +421,7 @@ public function proxyType()
|
|||||||
// return $proxyType;
|
// return $proxyType;
|
||||||
// }
|
// }
|
||||||
// if (is_null($proxyType)) {
|
// if (is_null($proxyType)) {
|
||||||
// $this->proxy->type = ProxyTypes::TRAEFIK_V2->value;
|
// $this->proxy->type = ProxyTypes::TRAEFIK->value;
|
||||||
// $this->proxy->status = ProxyStatus::EXITED->value;
|
// $this->proxy->status = ProxyStatus::EXITED->value;
|
||||||
// $this->save();
|
// $this->save();
|
||||||
// }
|
// }
|
||||||
|
@ -136,7 +136,7 @@ function generate_default_proxy_configuration(Server $server)
|
|||||||
'external' => true,
|
'external' => true,
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
if ($proxy_type === 'TRAEFIK_V2') {
|
if ($proxy_type === ProxyTypes::TRAEFIK->value) {
|
||||||
$labels = [
|
$labels = [
|
||||||
'traefik.enable=true',
|
'traefik.enable=true',
|
||||||
'traefik.http.routers.traefik.entrypoints=http',
|
'traefik.http.routers.traefik.entrypoints=http',
|
||||||
|
@ -100,7 +100,7 @@ public function run(): void
|
|||||||
'private_key_id' => 0,
|
'private_key_id' => 0,
|
||||||
];
|
];
|
||||||
$server_details['proxy'] = ServerMetadata::from([
|
$server_details['proxy'] = ServerMetadata::from([
|
||||||
'type' => ProxyTypes::TRAEFIK_V2->value,
|
'type' => ProxyTypes::TRAEFIK->value,
|
||||||
'status' => ProxyStatus::EXITED->value,
|
'status' => ProxyStatus::EXITED->value,
|
||||||
]);
|
]);
|
||||||
$server = Server::create($server_details);
|
$server = Server::create($server_details);
|
||||||
@ -153,7 +153,7 @@ public function run(): void
|
|||||||
'private_key_id' => 0,
|
'private_key_id' => 0,
|
||||||
];
|
];
|
||||||
$server_details['proxy'] = ServerMetadata::from([
|
$server_details['proxy'] = ServerMetadata::from([
|
||||||
'type' => ProxyTypes::TRAEFIK_V2->value,
|
'type' => ProxyTypes::TRAEFIK->value,
|
||||||
'status' => ProxyStatus::EXITED->value,
|
'status' => ProxyStatus::EXITED->value,
|
||||||
]);
|
]);
|
||||||
$server = Server::create($server_details);
|
$server = Server::create($server_details);
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
<button>Configuration</button>
|
<button>Configuration</button>
|
||||||
</a>
|
</a>
|
||||||
@if ($server->proxyType() !== 'NONE')
|
@if ($server->proxyType() !== 'NONE')
|
||||||
{{-- @if ($server->proxyType() === 'TRAEFIK_V2') --}}
|
{{-- @if ($server->proxyType() === 'TRAEFIK') --}}
|
||||||
<a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
|
<a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
|
||||||
href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
|
href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
|
||||||
<button>Dynamic Configurations</button>
|
<button>Dynamic Configurations</button>
|
||||||
</a>
|
</a>
|
||||||
{{-- @endif --}}
|
{{-- @endif --}}
|
||||||
<a class="{{ request()->routeIs('server.proxy.logs') ? 'dark:text-white' : '' }}"
|
<a class="{{ request()->routeIs('server.proxy.logs') ? 'dark:text-white' : '' }}"
|
||||||
href="{{ route('server.proxy.logs', $parameters) }}">
|
href="{{ route('server.proxy.logs', $parameters) }}">
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@php use App\Enums\ProxyTypes; @endphp
|
||||||
<div>
|
<div>
|
||||||
@if ($server->proxyType())
|
@if ($server->proxyType())
|
||||||
<div x-init="$wire.loadProxyConfiguration">
|
<div x-init="$wire.loadProxyConfiguration">
|
||||||
@ -20,7 +21,7 @@
|
|||||||
</svg>Before switching proxies, please read <a class="underline dark:text-white"
|
</svg>Before switching proxies, please read <a class="underline dark:text-white"
|
||||||
href="https://coolify.io/docs/knowledge-base/server/proxies#switch-between-proxies">this</a>.
|
href="https://coolify.io/docs/knowledge-base/server/proxies#switch-between-proxies">this</a>.
|
||||||
</div>
|
</div>
|
||||||
@if ($server->proxyType() === 'TRAEFIK_V2')
|
@if ($server->proxyType() === ProxyTypes::TRAEFIK->value)
|
||||||
<h4>Traefik</h4>
|
<h4>Traefik</h4>
|
||||||
@elseif ($server->proxyType() === 'CADDY')
|
@elseif ($server->proxyType() === 'CADDY')
|
||||||
<h4>Caddy</h4>
|
<h4>Caddy</h4>
|
||||||
@ -69,7 +70,7 @@
|
|||||||
<x-forms.button class="box" wire:click="select_proxy('NONE')">
|
<x-forms.button class="box" wire:click="select_proxy('NONE')">
|
||||||
Custom (None)
|
Custom (None)
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
<x-forms.button class="box" wire:click="select_proxy('TRAEFIK_V2')">
|
<x-forms.button class="box" wire:click="select_proxy('TRAEFIK')">
|
||||||
Traefik
|
Traefik
|
||||||
</x-forms.button>
|
</x-forms.button>
|
||||||
<x-forms.button class="box" wire:click="select_proxy('CADDY')">
|
<x-forms.button class="box" wire:click="select_proxy('CADDY')">
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
@php use App\Enums\ProxyTypes; @endphp
|
||||||
<div>
|
<div>
|
||||||
@if (
|
@if (
|
||||||
$server->proxyType() !== 'NONE' &&
|
$server->proxyType() !== 'NONE' &&
|
||||||
@ -12,7 +13,10 @@
|
|||||||
</x-slide-over>
|
</x-slide-over>
|
||||||
@if (data_get($server, 'proxy.status') === 'running')
|
@if (data_get($server, 'proxy.status') === 'running')
|
||||||
<div class="flex gap-2">
|
<div class="flex gap-2">
|
||||||
@if ($currentRoute === 'server.proxy' && $traefikDashboardAvailable && $server->proxyType() === 'TRAEFIK_V2')
|
@if (
|
||||||
|
$currentRoute === 'server.proxy' &&
|
||||||
|
$traefikDashboardAvailable &&
|
||||||
|
$server->proxyType() === ProxyTypes::TRAEFIK->value)
|
||||||
<button>
|
<button>
|
||||||
<a target="_blank" href="http://{{ $serverIp }}:8080">
|
<a target="_blank" href="http://{{ $serverIp }}:8080">
|
||||||
Traefik Dashboard
|
Traefik Dashboard
|
||||||
|
Loading…
Reference in New Issue
Block a user