diff --git a/Traefik.php b/Traefik.php index 4607ef4e6c2ed619b64715a9db435cf64bc01235..7948b38af45c6d30c5a81b9e9ceff16bfd7cee5f 100644 --- a/Traefik.php +++ b/Traefik.php @@ -45,19 +45,25 @@ class Traefik { } else { $fs->mkdir($traefikPath); + $fs->mkdir($traefikPath . '/certs'); + $cmd = 'openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout '; + $cmd .= $traefikPath . '/certs/key.pem -out ' . $traefikPath . '/certs/cert.pem'; + exec($cmd); $traefik = [ 'version' => '2', 'services' => [ 'traefik' => [ 'image' => 'traefik', 'restart' => 'unless-stopped', - 'command' => '-c /dev/null --web --docker --logLevel=DEBUG', + 'command' => '-c /dev/null --web --docker --logLevel=DEBUG --defaultEntryPoints="https" --defaultEntryPoints="http" --entryPoints="Name:https Address::443 TLS:/certs/cert.pem,/certs/key.pem" --entryPoints="Name:http Address::80"', 'networks' => [], 'ports' => [ '8000:80', + '443:443', '8080:8080', ], 'volumes' => [ + './certs:/certs/', '/var/run/docker.sock:/var/run/docker.sock', ], ],