Zipkin: Investigate custom context root

Created on 10 Aug 2016  路  32Comments  路  Source: openzipkin/zipkin

_From @adriancole on May 21, 2016 13:47_

https://github.com/openzipkin/docker-zipkin/issues/97 was opened about moving all zipkin things under the context root /zipkin (directly vs via a reverse proxy).

This might be possible with OOB spring boot. If so, we could consider this. Otherwise we can close it with explanation in case the question comes up again.

_Copied from original issue: openzipkin/zipkin-java#244_

enhancement ui

Most helpful comment

ok folks.. here it is https://github.com/openzipkin/zipkin/pull/1627

cc @sirtyro, too

All 32 comments

_From @shakuzen on May 22, 2016 1:37_

Should be as simple as setting server.contextPath or the equivalent environment variable SERVER_CONTEXT_PATH

_From @eirslett on May 25, 2016 8:51_

It's easy on the server side, but it would be non-trivial to implement, because our UI is a single-page web app, and it assumes absolute paths.

I've been able to relocate single-page web apps, but only when they used hash based client side routing. Once the single-page web app uses hash based routing, all API calls can use paths relative to location of the single page app. I don't know if this is an option here?

We could simply hardcode the UI to always be served under /zipkin/. And set up redirects, to that requests to the old URLs are automatically redirected to /zipkin/xxx.

current workarounds:

  • use something like nginx to do this. For example, how our docker image does
  • fork and edit the javascript like this

If we consider alternate paths on the default server, we also have to recognize the multiple endpoints zipkin serves, including /api/v1/* and /config.json etc. For example, this could lead to a whack-a-mole of changes and/or tests, especially as some have explicit cache response headers. That may be fine, but we should be aware of what all the various reasons people have. For example, do they also want the api root to change?

@adriancole I tried the second approach by changing the js source code as mentioned in your comment, then I built the zipkin-ui.jar and put it under the /zipkin/BOOT-INF/lib/ in the docker image , but it does not seem to work, it return 404 for following path,
/zipkin

am I missing something?

This feature would be a nice to have.

We have a standard-ish way of addressing apps and services in our architecture, which basically has the service name as the first element on the path. Various services , our service monitoring, health, and service discovery rely on this. We will be running zipkin-servers as a standard service (standard by our architecture) and hence we want to follow suite and follow our standard practices.

Having said that, we can quite easily work around that, so for the sake of keeping zipkin as standard as possible, that's our approach for now.

>

This feature would be a nice to have.

Thanks for the summary. Would changing the default context root to
"/zipkin" suffice? or would you need to control it.

I am running into this exact problem right now.

Having the root be /zipkin would at least make it possible to put behind a proxy, like zuul, provided the person implementing is happy to change their proxy configuration to fit with zipkin's root (or is able to change their proxy configuration, for some people this will not be an option).

Being able to configure the root would make putting the zipkin server and ui behind a proxy a lot easier and allow people to change zipkin to suit their network infrastructure needs, rather than getting their network infrastructure to suit zipkin's needs.

My current project would be fine with a root of /zipkin but this fix won't be a solution in all cases.

I like the idea of at least having it on /zipkin if nothing else.

K was mainly suggesting /zipkin as it seemed easier due to eirik's
comments, letting best not be enemy of good etc.

Any progress on this, would be nice to serve zipkin off a path under the main application's context, rather than off a different endpoint altogether. Seems like quite a big glaring omission for such a great tool!

Currently seems easiest+most acceptable way to implement this is by way of
/zipkin

Zipkin is mostly volunteers, waiting for one on this!

ok folks.. here it is https://github.com/openzipkin/zipkin/pull/1627

cc @sirtyro, too

out in zipkin 1.27

I just tried this out, not sure what I am doing wrong, but the api request is going to /api/v1 instead of /zipkin/api/v1 and since zipkin is setup behind a proxy /api/ will not get proxied to zipkin. Did I miss some setting?

>

I just tried this out, not sure what I am doing wrong, but the api request
is going to /api/v1 instead of /zipkin/api/v1 and since zipkin is setup
behind a proxy /api/ will not get proxied to zipkin. Did I miss some
setting?

No I think you just found a glitch. Eventhough we mapped /zipkin/api the
code in zipkin-ui/js/component_data still points to /api

Are you able to raise a PR to fix this? If so I can merge it tomorrow my
time and release a patch (I'm in malaysia time so nearly midnight)

any help kindly received.. it is probably all files in that dir. catch you
later!

When I try to go to /zipkin/api/v1/services on a local running server, and on the proxied server both are returning 404

I do not know why https://github.com/openzipkin/zipkin/commit/b9cfb3ecca506c9c013d0e2451bdd8fcdc162f05#diff-fc3d346937cd3a0d3094ab2716386dddR260 test is passing.

it seems like maybe there is something wrong with https://github.com/openzipkin/zipkin/commit/b9cfb3ecca506c9c013d0e2451bdd8fcdc162f05#diff-3f99bf822098bb694547a878f8e7b166R134 that specification but I have no idea how to fix that in spring.

I added

  @RequestMapping(value = "/zipkin/api/v1/services", method = GET)
  public ModelAndView forwardApiServices() {
    return new ModelAndView("forward:/api/v1/services");
  }

to that file and it worked as expected so just need to figure out how to do a route prefix correctly

Thanks for the hint.. I will try on my end, too.. must have messed up the
expression somehow

1.28.1 should hopefully fix this (on the way)

@adriancole
Could you tell me how to run a Zipkin under a custom path (like /services/zipkin)?

@gurinderu It's impossible, the only place it runs is under /zipkin/ (without /services).

@eirslett is it impossible to change a base href tag?

Yes, we don't control the HTML file from the server, it's just a static HTML file, so we cannot inject any attributes.

@eirslett Are you sure? we can modify index.html with a transformer in Spring

Have a go at it!

To save you effort it isn't so much the index.html as the bundled
javascript referenced by it. There are other things, too. Probably the more
straightforward way out is to address the redirect issue

>

@adriancole yep, I know.
But I think your last commit for this issue will help me)

@gurinderu good luck! and post back and/or let us know on gitter what you find https://gitter.im/openzipkin/zipkin

ps notice you're in st petersburg. I'll be there in oct for https://devoops.ru/

Was this page helpful?
0 / 5 - 0 ratings

Related issues

adriancole picture adriancole  路  6Comments

luoyongjiee picture luoyongjiee  路  5Comments

monicaplb picture monicaplb  路  4Comments

schrepfler picture schrepfler  路  7Comments

adriancole picture adriancole  路  13Comments