-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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 for running Zipkin behind a reverse proxy #1732
Conversation
- subfolder 'zipkin' is enforced - rewrite of the 'base' tag in the 'index.html' file is required
Thanks for taking a stab. Can you elaborate a little on how this leads to reverse proxy support, how it is tested, and if there are any README updates or otherwise needed? (ex in zipkin-ui for running locally) |
My use-case is quite simple, I need to run Zipkin in a different path than just The best solution would be to have all static links relative and let Javascript calculate the current url and not rely on With the changes I'm proposing, the good news is that if the reverse proxy supports rewriting of the static content ( It is of course possible to run Zipkin the same as before at the path Regarding tests and readme, I understand that both are important but I wanted to know how you feel about this change before updating the Docs. There are no tests ensuring that this functionality is preserved in future development. I propose to implement a single sanity integration test that Zipkin loads and that most common links work under a different path. |
… relative URI is returned for a redirect to 'zipkin/' subpath.
How will this work with the browser plugin for Zipkin? |
cc + @SimenB for testing relating to the browser plugin |
By the way, as for the test error reported by CircleCI:
I'm unable to reproduce that locally. Isn't it possible it's an intermittently failing test? If so, are you able to instruct CircleCI to re-run the test/build? In the worst case I could add a dummy commit to re-run it. |
sorry about the flake. kicked
|
Our reverse proxy setup is direct, we aren't modifying the paths at all so this won't affect me at the moment. But.. Can you put a blurb in the readme about the technical requirements for this to work? Also a sample apache config would probably be good. Thanks |
I would say the implementation itself isn't too bad, I imagined it would be more complex. Perhaps we should follow the rule-of-three? |
@adriancole similar to @devinsba, we don't modify the path and are not planning to any time soon. |
…bpack_public_path__' global variable.
To answer the question regarding the Apache Httpd configuration for the reverse proxying. (For now I'm not adding it to a readme, let me know if you have any suggestions where to put the information regarding reverse proxying.) Lets assume we want to access Zipkin (running on Apache Httpd configuration:
To access Zipkin UI behind the reverse proxy, execute:
As you can see, the attribute Uploading the span is easy as
And then it's of course observable in the UI:
|
By the way, in the latest commit I got rid of the |
How much effort would it take to fix the issue in html-webpack-plugin?
Sounds like a good idea, so we don't leak webpack-specific stuff everywhere in the code base |
zipkin-ui/js/publicPath.js
Outdated
// read the public path from the <base> tag where it has to be set anyway because of | ||
// html-webpack-plugin limitations: https://github.com/jantimon/html-webpack-plugin/issues/119 | ||
// otherwise it could be: window.location.pathname.replace(/(.*)\/zipkin\/.*/, '$1/zipkin/') | ||
const contextRoot = $('base').attr('href'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we sanity check that it ends with /
? Looks like the rest of the code assumes that. We could either show an error to the user, or just append /
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, I'll append /
if missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -21,7 +22,7 @@ export default component(function DefaultData() { | |||
const query = convertToApiQuery(window.location.search); | |||
const serviceName = query.serviceName; | |||
if (serviceName) { | |||
const apiURL = `/zipkin/api/v1/traces?${queryString.stringify(query)}`; | |||
const apiURL = `${contextRoot}api/v1/traces?${queryString.stringify(query)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a lot of code duplication going on here... maybe we should make a apiClient.js
which basically just accepts relative paths and wraps $.ajax
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. I'll take a look at it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. As a matter of fact, the $.ajax
call with relative paths use the <base>
tag and as such there was no need to wrap it as you suggested.
@eirslett, to be honest, I wanted to avoid even looking at the |
And the fact that |
…ase' html). Appending '/' to the 'contextRoot' if not present.
I pushed new changes. |
sorry about the delay. trying now. I really like this, actually. a lot tighter than I expected it to be. |
tested and looks very good. I'd add your comments about how to run in apache as an README.md section. A favor.. we broke local dev mode at some point. Can you help fix |
Fixed running in a 'devServer' mode. Assuming the 'zipkin-server' runs at 'localhost:9411', execute: proxy=http://localhost:9411/zipkin/ ./npm.sh run dev
@adriancole, I pushed another commit with extended README.md and fixed devServer.
|
very nice work. |
* Support for running Zipkin behind a reverse proxy - subfolder 'zipkin' is enforced - rewrite of the 'base' tag in the 'index.html' file is required * Fixed 'redirectedHeaderUsesOriginalHostAndPort' test to ensure that a relative URI is returned for a redirect to 'zipkin/' subpath. * Using 'contextRoot' as a code style conforming reference to the '__webpack_public_path__' global variable. * Using relative URIs for AJAX calls (which works thanks to the 'head>base' html). Appending '/' to the 'contextRoot' if not present. * Added readme regarding running behind a reverse proxy. Fixed running in a 'devServer' mode. Assuming the 'zipkin-server' runs at 'localhost:9411', execute: proxy=http://localhost:9411/zipkin/ ./npm.sh run dev
* Support for running Zipkin behind a reverse proxy - subfolder 'zipkin' is enforced - rewrite of the 'base' tag in the 'index.html' file is required * Fixed 'redirectedHeaderUsesOriginalHostAndPort' test to ensure that a relative URI is returned for a redirect to 'zipkin/' subpath. * Using 'contextRoot' as a code style conforming reference to the '__webpack_public_path__' global variable. * Using relative URIs for AJAX calls (which works thanks to the 'head>base' html). Appending '/' to the 'contextRoot' if not present. * Added readme regarding running behind a reverse proxy. Fixed running in a 'devServer' mode. Assuming the 'zipkin-server' runs at 'localhost:9411', execute: proxy=http://localhost:9411/zipkin/ ./npm.sh run dev
This implements the #1731