private URIBuilder createBasicURI(String scheme) throws URISyntaxException {
    URIBuilder uriBuilder = new URIBuilder();
    if (StringUtils.isNotBlank(externalAddress)) {
      final URI uri = new URI(externalAddress);
      uriBuilder.setScheme(uri.getScheme());
      uriBuilder.setHost(uri.getHost());
      if (uri.getPort() != -1) {
        uriBuilder.setPort(uri.getPort());
      }
      // add path as well to make it work with proxies like: https://sample.org/logsearch
      if (StringUtils.isNotBlank(uri.getPath())) {
        uriBuilder.setPath(uri.getPath());
      }
    } else {
      uriBuilder.setScheme(scheme);
      uriBuilder.setHost(hostName);
      uriBuilder.setPort(Integer.parseInt(portNumber));
    }
    return uriBuilder;
  }
Generates the log file tail URI, using the LogSearch server's
query parameters.

@param baseURI the base URI for this request, typically the URI to the
               Ambari Integration searchEngine component

@param componentName the component name
@param hostName the host name

@return
ambari-server/src/main/java/org/apache/ambari/server/controller/logging/LoggingRequestHelperImpl.java