t-rex-tileserver / t-rex

t-rex is a vector tile server specialized on publishing MVT tiles from your own data
https://t-rex.tileserver.ch/
MIT License
545 stars 68 forks source link

allow t-rex to run on another endpoint than root #241

Open tobwen opened 3 years ago

tobwen commented 3 years ago

background

I'm running NGINX as a remote proxy for t-rex on endpoint example.org/mvt/. I want to be able to have access to the "debug view" of t-rex, which is protected by HTTP Basic authentication.

issue

It seems like t-rex is designed to work on the root endpoint only (example.org/). All the static websites are linked to root, f.e. https://github.com/t-rex-tileserver/t-rex/blob/d5a67c47a1e2cf21a29b63bf820ed749f1cad911/t-rex-webserver/src/static/index.html#L1

As you can see, index.html always tries to read the JS-files from example.org/ instead of example.org/mvt/ - so normal rewriting the URL doesn't help.

what I've tried

  1. Of course, I'm aware of https://github.com/t-rex-tileserver/t-rex/issues/83, but none of the headers apply to index.html.
  2. I tried to use NGINX substitutions (https://nginx.org/en/docs/http/ngx_http_sub_module.html), but it isn't able to read HTML content from t-rex, seems like it's compressed?
  3. I then modified index.html and friends and put it into the static directory. It loaded up, but the layers haven't been loaded. It all resulted to NULL only. Seems like static cannot be used for this.

suggestions

MapProxy and other applications listen to the X-Script-Name and take care of this. With https://github.com/t-rex-tileserver/t-rex/issues/83 you actually have similar abilities, but for the JSON files, not for the "debug view". Could you add this? It would be really nice to have a realtime look into the data, even when it's running on a non-root location.

pka commented 3 years ago

You're right, the backend application has hardcoded paths assuming running on /. A workaround could be copying and adjusting the backend HTML/CSS/JS files and serve them as static assets (https://t-rex.tileserver.ch/doc/reference/#webserver)