$upstreams */ public function render(EnvironmentAttachment $attachment, array $upstreams): string { $config = $attachment->serviceSlice?->config ?? []; $domain = $config['domain'] ?? $attachment->serviceSlice?->name ?? $attachment->environment->name; $pathPrefix = $config['path_prefix'] ?? '/'; $siteAddress = ($config['tls_enabled'] ?? true) ? $domain : "http://{$domain}"; $upstreamTargets = $upstreams === [] ? ['web:80'] : $upstreams; if ($pathPrefix === '/') { return implode("\n", [ "{$siteAddress} {", ' reverse_proxy '.implode(' ', $upstreamTargets), '}', ]); } $normalizedPath = rtrim($pathPrefix, '/'); return implode("\n", [ "{$siteAddress} {", " handle_path {$normalizedPath}* {", ' reverse_proxy '.implode(' ', $upstreamTargets), ' }', '}', ]); } }