Fix: Scheme-Erkennung via APP_URL + nginx-Config statt letsencrypt-Pfad
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>main v1.1.297
parent
4fc31726be
commit
26eb3abdcd
|
|
@ -44,11 +44,8 @@ class MigrateEnvReverb extends Command
|
|||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
$hasCert = file_exists("/etc/letsencrypt/renewal/{$appHost}.conf")
|
||||
|| is_dir("/etc/letsencrypt/live/{$appHost}")
|
||||
|| file_exists("/etc/letsencrypt/live/{$appHost}/fullchain.pem");
|
||||
$scheme = $hasCert ? 'https' : 'http';
|
||||
$port = $hasCert ? '443' : '80';
|
||||
$scheme = $this->detectScheme($appHost, $content);
|
||||
$port = $scheme === 'https' ? '443' : '80';
|
||||
|
||||
$fixes = [
|
||||
'REVERB_HOST' => '${APP_HOST}',
|
||||
|
|
@ -93,6 +90,28 @@ class MigrateEnvReverb extends Command
|
|||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
private function detectScheme(string $host, string $envContent): string
|
||||
{
|
||||
// 1. APP_URL in .env bereits https?
|
||||
$appUrl = $this->extractVar($envContent, 'APP_URL');
|
||||
if (str_starts_with($appUrl, 'https://')) return 'https';
|
||||
|
||||
// 2. nginx-Konfiguration prüfen (world-readable)
|
||||
foreach (glob('/etc/nginx/sites-enabled/*') ?: [] as $f) {
|
||||
$c = @file_get_contents($f) ?: '';
|
||||
if (str_contains($c, $host) && str_contains($c, 'ssl_certificate')) return 'https';
|
||||
}
|
||||
|
||||
// 3. letsencrypt-Pfade (falls doch lesbar)
|
||||
if (file_exists("/etc/letsencrypt/renewal/{$host}.conf")
|
||||
|| is_dir("/etc/letsencrypt/live/{$host}")
|
||||
|| file_exists("/etc/letsencrypt/live/{$host}/fullchain.pem")) {
|
||||
return 'https';
|
||||
}
|
||||
|
||||
return 'http';
|
||||
}
|
||||
|
||||
private function extractVar(string $content, string $key): string
|
||||
{
|
||||
preg_match("/^{$key}=(.*)$/m", $content, $m);
|
||||
|
|
|
|||
Loading…
Reference in New Issue