Support serving Tiled from a sub-path.
A common use case for this is combining tiled with other services and UI apps behind a single reverse proxy server (nginx, k8s ingress nginx, traefik, etc.)
Say you had a user interface that accessed tiled for some or all of its data. You would want several routes that your reverse proxy server could use for dispatching requests:
-
/The entry route to the user interface, no sub-path to bother your users with -
/tiledThe path to tiled -
/another_service
This is really difficult to do today, because tiled can only process requests to /. The only solution that I know of here is to setup the reverse proxy to expose /tiled for external services (making it the public-facing url for tiled) and then re-write the path in every request before sending to tiled. This is a lot of work and gets confusing.
It would be better if we could configure the root path that tiled responds to.
For Future Us, remember this comment suggesting a way forward here: https://github.com/bluesky/tiled/pull/347#issuecomment-1410934348
Addressed by https://github.com/bluesky/tiled/pull/646 but needs docs. A working nginx config is over in https://github.com/bluesky/bluesky-pods/pull/37.
To be fair, #646 just makes it possible to configure the whole thing to sit behind nginx with no extra re-writing. The thing it does not do is move the /ui to / and the landing page with hints off to someplace else.
I'm now confused.
With #646, can I somehow mount all of tiled to, say, http://localhost/tiled and see both the ui homepage run at that URL, and point the python tiled client to that URL? If so, I'm super excited.
The ui is at http://localhost/tiled/ui and the API is at http://localhost/tiled/api
And is tiled configurable? Could the by http://localhost/toms_awesome_data_server/ui?
yes.
With the right nginx config (and a second tiled instance) you could even have http://localhost/toms_awesome_data_server/ui and http://localhost/dylans_awesome_data_server/ui running next to each other.
Config, lifted from https://github.com/bluesky/bluesky-pods/pull/37:
location ^~ /tiled/ {
proxy_pass http://tld:8000/;
proxy_read_timeout 60s;
# May not need or want to set Host. Should default to the above hostname.
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Host $host:11973;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
should probably use $server_port rather than a hard-coded port number