From dd99ad0af8f505b66b8ab54c5e85108c606c65c6 Mon Sep 17 00:00:00 2001 From: Andras Bacsai Date: Mon, 11 Dec 2023 20:29:40 +0100 Subject: [PATCH] fix fox --- app/Livewire/Settings/Configuration.php | 112 +----------------------- 1 file changed, 1 insertion(+), 111 deletions(-) diff --git a/app/Livewire/Settings/Configuration.php b/app/Livewire/Settings/Configuration.php index c2ed5f656..43f4afb7a 100644 --- a/app/Livewire/Settings/Configuration.php +++ b/app/Livewire/Settings/Configuration.php @@ -71,117 +71,7 @@ public function submit() private function setup_instance_fqdn() { - $file = "$this->dynamic_config_path/coolify.yaml"; - if (empty($this->settings->fqdn)) { - instant_remote_process([ - "rm -f $file", - ], $this->server); - } else { - $url = Url::fromString($this->settings->fqdn); - $host = $url->getHost(); - $schema = $url->getScheme(); - $traefik_dynamic_conf = [ - 'http' => - [ - 'routers' => - [ - 'coolify-http' => - [ - 'entryPoints' => [ - 0 => 'http', - ], - 'service' => 'coolify', - 'rule' => "Host(`{$host}`)", - ], - 'coolify-realtime-ws' => - [ - 'entryPoints' => [ - 0 => 'http', - ], - 'service' => 'coolify-realtime', - 'rule' => "Host(`{$host}`) && PathPrefix(`/realtime/`)", - ], - ], - 'services' => - [ - 'coolify' => - [ - 'loadBalancer' => - [ - 'servers' => - [ - 0 => - [ - 'url' => 'http://coolify:80', - ], - ], - ], - ], - 'coolify-realtime' => - [ - 'loadBalancer' => - [ - 'servers' => - [ - 0 => - [ - 'url' => 'http://coolify-realtime:6001', - ], - ], - ], - ], - ], - ], - ]; + setup_dynamic_configuration(); - if ($schema === 'https') { - $traefik_dynamic_conf['http']['routers']['coolify-http']['middlewares'] = [ - 0 => 'redirect-to-https@docker', - ]; - $traefik_dynamic_conf['http']['routers']['coolify-realtime-wss']['middlewares'] = [ - 0 => 'redirect-to-https@docker', - ]; - $traefik_dynamic_conf['http']['routers']['coolify-https'] = [ - 'entryPoints' => [ - 0 => 'https', - ], - 'service' => 'coolify', - 'rule' => "Host(`{$host}`)", - 'tls' => [ - 'certresolver' => 'letsencrypt', - ], - ]; - $traefik_dynamic_conf['http']['routers']['coolify-realtime-wss'] = [ - 'entryPoints' => [ - 0 => 'https', - ], - 'service' => 'coolify-realtime', - 'rule' => "Host(`{$host}`) && PathPrefix(`/realtime/`)", - 'tls' => [ - 'certresolver' => 'letsencrypt', - ], - ]; - } - $this->save_configuration_to_disk($traefik_dynamic_conf, $file); - } - } - - private function save_configuration_to_disk(array $traefik_dynamic_conf, string $file) - { - $yaml = Yaml::dump($traefik_dynamic_conf, 12, 2); - $yaml = - "# This file is automatically generated by Coolify.\n" . - "# Do not edit it manually (only if you know what are you doing).\n\n" . - $yaml; - - $base64 = base64_encode($yaml); - instant_remote_process([ - "mkdir -p $this->dynamic_config_path", - "echo '$base64' | base64 -d > $file", - ], $this->server); - - if (config('app.env') == 'local') { - ray($yaml); - } } }