Search code examples
javaproxykibanajetty-9

using jetty as reverse proxy for kibana


we are try to hide the kibana server behind a jetty and use it as reverse proxy.
what happens is that we do mange to get the index html file from kibana but when the page tries to retrieve its images and css it fails with 404. what we see is that wen we try to get the index html we go to:http://localhost:8181/sdc1/kibanaProxy

however whne the page trys to access the css it goes to :
http://localhost:8181/sdc1/styles/main.css?_b=7616

this is my proxy function in the jetty proxy servlet:

public URI rewriteURI(HttpServletRequest request) {
    String requestURI = request.getRequestURI();
    String originalUrl = request.getRequestURL().toString();
    String suffix = requestURI.replace("/sdc1/kibanaProxy", "/");
    String redirectedUrl = new     StringBuilder("http://localhost:5601").append(suffix).toString();
    log.debug("KibanaServlet Redirecting request from: {} , to: {}", originalUrl, redirectedUrl);
    return URI.create(redirectedUrl);
}

now i know that kibana can work behind a proxy using nginx. what am i missing?


Solution

  • in the end the root cause was that for kibana to retrieve all the required component( css images etc) we need to change the proxy url to one that ends with / /sdc1/kibanaProxy --> /sdc1/kibanaProxy/

    and that solves all the problem.