private function createServerAttributes(PortalInformation $portalInformation, Request $currentRequest = null)
    {
        // get server parameters
        $server = [];
        $host = null;
        // FIXME default scheme and port should be configurable.
        $scheme = 'http';
        $port = 80;

        if ($currentRequest) {
            $server = $currentRequest->server->all();
            $scheme = $currentRequest->getScheme();
            $host = $currentRequest->getHost();
            $port = $currentRequest->getPort();
        }

        $portalUrl = $scheme . '://' . $this->replacer->replaceHost($portalInformation->getUrl(), $host);
        $portalUrlParts = parse_url($portalUrl);
        $prefixPath = isset($portalUrlParts['path']) ? $portalUrlParts['path'] : '';

        $httpHost = $portalUrlParts['host'];
        if (!in_array($port, [80, 443])) {
            $httpHost .= ':' . $port;
        }

        $server['SERVER_NAME'] = $portalUrlParts['host'];
        $server['SERVER_PORT'] = $port;
        $server['HTTP_HOST'] = $httpHost;
        $server['REQUEST_URI'] = $prefixPath . '/_sulu_preview';
        unset($server['HTTP_X_REQUESTED_WITH']); // subrequest should not be detected as ajax

        return $server;
    }