refactor: Update ProxyTypes enum values to use TRAEFIK instead of TRAEFIK_V2
This commit is contained in:
		@@ -5,7 +5,7 @@ namespace App\Enums;
 | 
			
		||||
enum ProxyTypes: string
 | 
			
		||||
{
 | 
			
		||||
    case NONE = 'NONE';
 | 
			
		||||
    case TRAEFIK_V2 = 'TRAEFIK_V2';
 | 
			
		||||
    case TRAEFIK = 'TRAEFIK';
 | 
			
		||||
    case NGINX = 'NGINX';
 | 
			
		||||
    case CADDY = 'CADDY';
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -525,7 +525,7 @@ class ServersController extends Controller
 | 
			
		||||
            'private_key_id' => $privateKey->id,
 | 
			
		||||
            'team_id' => $teamId,
 | 
			
		||||
            'proxy' => [
 | 
			
		||||
                'type' => ProxyTypes::TRAEFIK_V2->value,
 | 
			
		||||
                'type' => ProxyTypes::TRAEFIK->value,
 | 
			
		||||
                'status' => ProxyStatus::EXITED->value,
 | 
			
		||||
            ],
 | 
			
		||||
        ]);
 | 
			
		||||
 
 | 
			
		||||
@@ -179,7 +179,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
 | 
			
		||||
    public function getProxyType()
 | 
			
		||||
    {
 | 
			
		||||
        // Set Default Proxy Type
 | 
			
		||||
        $this->selectProxy(ProxyTypes::TRAEFIK_V2->value);
 | 
			
		||||
        $this->selectProxy(ProxyTypes::TRAEFIK->value);
 | 
			
		||||
        // $proxyTypeSet = $this->createdServer->proxy->type;
 | 
			
		||||
        // if (!$proxyTypeSet) {
 | 
			
		||||
        //     $this->currentState = 'select-proxy';
 | 
			
		||||
 
 | 
			
		||||
@@ -104,7 +104,7 @@ class ByIp extends Component
 | 
			
		||||
                'private_key_id' => $this->private_key_id,
 | 
			
		||||
                'proxy' => [
 | 
			
		||||
                    // set default proxy type to traefik v2
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK_V2->value,
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK->value,
 | 
			
		||||
                    'status' => ProxyStatus::EXITED->value,
 | 
			
		||||
                ],
 | 
			
		||||
            ];
 | 
			
		||||
 
 | 
			
		||||
@@ -2,6 +2,7 @@
 | 
			
		||||
 | 
			
		||||
namespace App\Livewire\Server\Proxy;
 | 
			
		||||
 | 
			
		||||
use App\Enums\ProxyTypes;
 | 
			
		||||
use App\Models\Server;
 | 
			
		||||
use Livewire\Component;
 | 
			
		||||
use Symfony\Component\Yaml\Yaml;
 | 
			
		||||
@@ -45,7 +46,7 @@ class NewDynamicConfiguration extends Component
 | 
			
		||||
                return redirect()->route('server.index');
 | 
			
		||||
            }
 | 
			
		||||
            $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')) {
 | 
			
		||||
                    $this->fileName = "{$this->fileName}.yaml";
 | 
			
		||||
                }
 | 
			
		||||
@@ -69,7 +70,7 @@ class NewDynamicConfiguration extends Component
 | 
			
		||||
                    return;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            if ($proxy_type === 'TRAEFIK_V2') {
 | 
			
		||||
            if ($proxy_type === ProxyTypes::TRAEFIK->value) {
 | 
			
		||||
                $yaml = Yaml::parse($this->value);
 | 
			
		||||
                $yaml = Yaml::dump($yaml, 10, 2);
 | 
			
		||||
                $this->value = $yaml;
 | 
			
		||||
 
 | 
			
		||||
@@ -151,7 +151,7 @@ class Server extends BaseModel
 | 
			
		||||
        $dynamic_conf_path = $this->proxyPath().'/dynamic';
 | 
			
		||||
        $proxy_type = $this->proxyType();
 | 
			
		||||
        $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";
 | 
			
		||||
        } elseif ($proxy_type === 'CADDY') {
 | 
			
		||||
            $default_redirect_file = "$dynamic_conf_path/default_redirect_404.caddy";
 | 
			
		||||
@@ -181,7 +181,7 @@ respond 404
 | 
			
		||||
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
        if ($proxy_type === 'TRAEFIK_V2') {
 | 
			
		||||
        if ($proxy_type === ProxyTypes::TRAEFIK->value) {
 | 
			
		||||
            $dynamic_conf = [
 | 
			
		||||
                'http' => [
 | 
			
		||||
                    'routers' => [
 | 
			
		||||
@@ -255,7 +255,7 @@ respond 404
 | 
			
		||||
    {
 | 
			
		||||
        $settings = \App\Models\InstanceSettings::get();
 | 
			
		||||
        $dynamic_config_path = $this->proxyPath().'/dynamic';
 | 
			
		||||
        if ($this->proxyType() === 'TRAEFIK_V2') {
 | 
			
		||||
        if ($this->proxyType() === ProxyTypes::TRAEFIK->value) {
 | 
			
		||||
            $file = "$dynamic_config_path/coolify.yaml";
 | 
			
		||||
            if (empty($settings->fqdn) || (isCloud() && $this->id !== 0) || ! $this->isLocalhost()) {
 | 
			
		||||
                instant_remote_process([
 | 
			
		||||
@@ -403,7 +403,7 @@ $schema://$host {
 | 
			
		||||
        // TODO: should use /traefik for already exisiting configurations?
 | 
			
		||||
        // Should move everything except /caddy and /nginx to /traefik
 | 
			
		||||
        // 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;
 | 
			
		||||
        } elseif ($proxyType === ProxyTypes::CADDY->value) {
 | 
			
		||||
            $proxy_path = $proxy_path.'/caddy';
 | 
			
		||||
@@ -421,7 +421,7 @@ $schema://$host {
 | 
			
		||||
        //     return $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->save();
 | 
			
		||||
        // }
 | 
			
		||||
 
 | 
			
		||||
@@ -136,7 +136,7 @@ function generate_default_proxy_configuration(Server $server)
 | 
			
		||||
            'external' => true,
 | 
			
		||||
        ];
 | 
			
		||||
    });
 | 
			
		||||
    if ($proxy_type === 'TRAEFIK_V2') {
 | 
			
		||||
    if ($proxy_type === ProxyTypes::TRAEFIK->value) {
 | 
			
		||||
        $labels = [
 | 
			
		||||
            'traefik.enable=true',
 | 
			
		||||
            'traefik.http.routers.traefik.entrypoints=http',
 | 
			
		||||
 
 | 
			
		||||
@@ -100,7 +100,7 @@ class ProductionSeeder extends Seeder
 | 
			
		||||
                    'private_key_id' => 0,
 | 
			
		||||
                ];
 | 
			
		||||
                $server_details['proxy'] = ServerMetadata::from([
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK_V2->value,
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK->value,
 | 
			
		||||
                    'status' => ProxyStatus::EXITED->value,
 | 
			
		||||
                ]);
 | 
			
		||||
                $server = Server::create($server_details);
 | 
			
		||||
@@ -153,7 +153,7 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
 | 
			
		||||
                    'private_key_id' => 0,
 | 
			
		||||
                ];
 | 
			
		||||
                $server_details['proxy'] = ServerMetadata::from([
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK_V2->value,
 | 
			
		||||
                    'type' => ProxyTypes::TRAEFIK->value,
 | 
			
		||||
                    'status' => ProxyStatus::EXITED->value,
 | 
			
		||||
                ]);
 | 
			
		||||
                $server = Server::create($server_details);
 | 
			
		||||
 
 | 
			
		||||
@@ -5,11 +5,11 @@
 | 
			
		||||
            <button>Configuration</button>
 | 
			
		||||
        </a>
 | 
			
		||||
        @if ($server->proxyType() !== 'NONE')
 | 
			
		||||
            {{-- @if ($server->proxyType() === 'TRAEFIK_V2') --}}
 | 
			
		||||
                <a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
 | 
			
		||||
                    href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
 | 
			
		||||
                    <button>Dynamic Configurations</button>
 | 
			
		||||
                </a>
 | 
			
		||||
            {{-- @if ($server->proxyType() === 'TRAEFIK') --}}
 | 
			
		||||
            <a class="{{ request()->routeIs('server.proxy.dynamic-confs') ? 'dark:text-white' : '' }}"
 | 
			
		||||
                href="{{ route('server.proxy.dynamic-confs', $parameters) }}">
 | 
			
		||||
                <button>Dynamic Configurations</button>
 | 
			
		||||
            </a>
 | 
			
		||||
            {{-- @endif --}}
 | 
			
		||||
            <a class="{{ request()->routeIs('server.proxy.logs') ? 'dark:text-white' : '' }}"
 | 
			
		||||
                href="{{ route('server.proxy.logs', $parameters) }}">
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
@php use App\Enums\ProxyTypes; @endphp
 | 
			
		||||
<div>
 | 
			
		||||
    @if ($server->proxyType())
 | 
			
		||||
        <div x-init="$wire.loadProxyConfiguration">
 | 
			
		||||
@@ -20,7 +21,7 @@
 | 
			
		||||
                        </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>.
 | 
			
		||||
                    </div>
 | 
			
		||||
                    @if ($server->proxyType() === 'TRAEFIK_V2')
 | 
			
		||||
                    @if ($server->proxyType() === ProxyTypes::TRAEFIK->value)
 | 
			
		||||
                        <h4>Traefik</h4>
 | 
			
		||||
                    @elseif ($server->proxyType() === 'CADDY')
 | 
			
		||||
                        <h4>Caddy</h4>
 | 
			
		||||
@@ -69,7 +70,7 @@
 | 
			
		||||
                    <x-forms.button class="box" wire:click="select_proxy('NONE')">
 | 
			
		||||
                        Custom (None)
 | 
			
		||||
                    </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
 | 
			
		||||
                    </x-forms.button>
 | 
			
		||||
                    <x-forms.button class="box" wire:click="select_proxy('CADDY')">
 | 
			
		||||
 
 | 
			
		||||
@@ -1,3 +1,4 @@
 | 
			
		||||
@php use App\Enums\ProxyTypes; @endphp
 | 
			
		||||
<div>
 | 
			
		||||
    @if (
 | 
			
		||||
        $server->proxyType() !== 'NONE' &&
 | 
			
		||||
@@ -12,7 +13,10 @@
 | 
			
		||||
        </x-slide-over>
 | 
			
		||||
        @if (data_get($server, 'proxy.status') === 'running')
 | 
			
		||||
            <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>
 | 
			
		||||
                        <a target="_blank" href="http://{{ $serverIp }}:8080">
 | 
			
		||||
                            Traefik Dashboard
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user