private static String getHttpURL() { RequestContext context = getContext(); String xForwardedHost = context.getXForwardedHost(); if ( xForwardedHost != null && xForwardedHost != "" ) { String contextServiceUrl = context.getServiceUrl(); try { URL serviceUrl = new URL( contextServiceUrl ); return buildUrlFromForwardedHeader( context, serviceUrl ); } catch ( MalformedURLException e ) { LOG.warn( "Could not parse service URL as URL: " + contextServiceUrl ); } } return context.getServiceUrl(); }