do not use traefik host now

This commit is contained in:
Andras Bacsai 2023-05-25 21:28:10 +02:00
parent 3ba9f399b8
commit 80c63e5701
2 changed files with 15 additions and 21 deletions

View File

@ -2,12 +2,9 @@
namespace App\Actions\Proxy; namespace App\Actions\Proxy;
use App\Enums\ActivityTypes;
use App\Models\InstanceSettings;
use App\Models\Server; use App\Models\Server;
use Spatie\Activitylog\Models\Activity; use Spatie\Activitylog\Models\Activity;
use Illuminate\Support\Str; use Illuminate\Support\Str;
use Spatie\Url\Url;
class InstallProxy class InstallProxy
{ {
@ -37,16 +34,16 @@ class InstallProxy
$server->extra_attributes->last_applied_proxy_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value; $server->extra_attributes->last_applied_proxy_settings = Str::of($docker_compose_yml_base64)->pipe('md5')->value;
$server->save(); $server->save();
$env_file_base64 = base64_encode( // $env_file_base64 = base64_encode(
$this->getEnvContents() // $this->getEnvContents()
); // );
$activity = remote_process([ $activity = remote_process([
...$create_networks_command, ...$create_networks_command,
"echo 'Docker networks created...'", "echo 'Docker networks created...'",
"mkdir -p $proxy_path", "mkdir -p $proxy_path",
"cd $proxy_path", "cd $proxy_path",
"echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml", "echo '$docker_compose_yml_base64' | base64 -d > $proxy_path/docker-compose.yml",
"echo '$env_file_base64' | base64 -d > $proxy_path/.env", // "echo '$env_file_base64' | base64 -d > $proxy_path/.env",
"echo 'Docker compose file created...'", "echo 'Docker compose file created...'",
"echo 'Pulling docker image...'", "echo 'Pulling docker image...'",
'docker compose pull -q', 'docker compose pull -q',
@ -60,18 +57,15 @@ class InstallProxy
return $activity; return $activity;
} }
protected function getEnvContents() // protected function getEnvContents()
{ // {
$instance_fqdn = InstanceSettings::get()->fqdn ?? config('app.url'); // $data = [
$url = Url::fromString($instance_fqdn); // 'LETS_ENCRYPT_EMAIL' => '',
$data = [ // ];
'TRAEFIK_DASHBOARD_HOST' => $url->getHost(),
'LETS_ENCRYPT_EMAIL' => '',
];
return collect($data) // return collect($data)
->map(fn ($v, $k) => "{$k}={$v}") // ->map(fn ($v, $k) => "{$k}={$v}")
->push(PHP_EOL) // ->push(PHP_EOL)
->implode(PHP_EOL); // ->implode(PHP_EOL);
} // }
} }

View File

@ -59,10 +59,10 @@ if (!function_exists('getProxyConfiguration')) {
"labels" => [ "labels" => [
"traefik.enable=true", "traefik.enable=true",
"traefik.http.routers.traefik.entrypoints=http", "traefik.http.routers.traefik.entrypoints=http",
'traefik.http.routers.traefik.rule=Host(`${TRAEFIK_DASHBOARD_HOST}`)',
"traefik.http.routers.traefik.middlewares=traefik-basic-auth@file", "traefik.http.routers.traefik.middlewares=traefik-basic-auth@file",
"traefik.http.routers.traefik.service=api@internal", "traefik.http.routers.traefik.service=api@internal",
"traefik.http.services.traefik.loadbalancer.server.port=8080", "traefik.http.services.traefik.loadbalancer.server.port=8080",
// Global Middlewares
"traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https", "traefik.http.middlewares.redirect-to-https.redirectscheme.scheme=https",
"traefik.http.middlewares.gzip.compress=true", "traefik.http.middlewares.gzip.compress=true",
], ],