Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support running Kafka Webview behind reverse proxy #136

Closed
wkerckho opened this issue Feb 18, 2019 · 8 comments · Fixed by #137
Closed

Support running Kafka Webview behind reverse proxy #136

wkerckho opened this issue Feb 18, 2019 · 8 comments · Fixed by #137

Comments

@wkerckho
Copy link

I am running Kafka Webview in a Kubernetes cluster and I'm trying to expose it publicly using Kubernetes Ingress (reverse proxy mechanism, backed by traefik).

I want to setup a reverse proxy rewrite rule that translates all external requests that matche the path prefix /dashboards/kafka to / on the service that is running Kafka Webview. This works for accessing the index page or the static resources, but the page links are incorrent and redirects fail, because your are using absolute paths in the JSP templates (e.g. the authentication procedure automatically redirects to /login, but should be login so it is externally reachable from /dashboards/kafka/login through the reverse proxy).

Another solution could be to use the Spring Boot server.servlet.configPath configuration property. Using this property I could set a prefix path for the Kafka Webview (dashboards/kafka) and let the reverse proxy redirect the paths as-is. For this to work, I guess you should add the variable ${pageContext.request.contextPath} before all href paths?

Or is there another easy workaround?

@Crim
Copy link
Collaborator

Crim commented Feb 19, 2019

So I've made a first pass in the above PR to properly prefix the URLs in the templates making use of the server.servlet.context-path configuration property which can be defined in the application.yml file distributed with each release.

Unfortunately the above PR doesn't handle ALL of the URLs, most notably any generated from within javascript, or some links defined in CSS files (like font-awesome). I'll have to do some tinkering around to figure out how to sort those out.

@Crim
Copy link
Collaborator

Crim commented Feb 19, 2019

OK, I believe master now contains the required fixes to make this work. Are you able to validate from master?

You'll need to edit your config.yml file and add the following:

server:
  servlet:
    context-path: /prefix/here

@wkerckho
Copy link
Author

I checked the master and I was able to successfully set a context-path. Routing through the reverse proxy is now possible! Thank you very much!

Any idea on when this version might be available as a Docker image?

@Crim
Copy link
Collaborator

Crim commented Feb 19, 2019

I'll cut a release tomorrow for you, let me know if you run into any issues before that.

Thanks for reporting the issue!

@Crim
Copy link
Collaborator

Crim commented Feb 19, 2019

Docker images should be updated.

@wkerckho
Copy link
Author

Super! I've got the Kafka Webview up and running in our Kubernetes cluster now!

@Crim
Copy link
Collaborator

Crim commented Feb 20, 2019

Great, going to close out this issue. Will post up a proper release here on github shortly.

@Crim Crim closed this as completed Feb 20, 2019
@wkerckho
Copy link
Author

Could it be that the websocket endpoint for the streaming view still needs to be prefixed?

When I click the connect button, it tries a GET https://myhost/websocket/info?t=1550846293947, but this should also be GET https://myhost/{configured pathPrefix}/websocket/info?t=1550846293947.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants