tiled icon indicating copy to clipboard operation
tiled copied to clipboard

Support serving Tiled from a sub-path.

Open danielballan opened this issue 3 years ago • 10 comments

danielballan avatar Aug 08 '22 11:08 danielballan

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
  • /tiled The 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.

dylanmcreynolds avatar Aug 08 '22 14:08 dylanmcreynolds

For Future Us, remember this comment suggesting a way forward here: https://github.com/bluesky/tiled/pull/347#issuecomment-1410934348

danielballan avatar Jun 01 '23 00:06 danielballan

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.

danielballan avatar Feb 02 '24 21:02 danielballan

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.

tacaswell avatar Feb 02 '24 21:02 tacaswell

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.

dylanmcreynolds avatar Feb 05 '24 17:02 dylanmcreynolds

The ui is at http://localhost/tiled/ui and the API is at http://localhost/tiled/api

tacaswell avatar Feb 05 '24 18:02 tacaswell

And is tiled configurable? Could the by http://localhost/toms_awesome_data_server/ui?

dylanmcreynolds avatar Feb 05 '24 19:02 dylanmcreynolds

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.

tacaswell avatar Feb 05 '24 19:02 tacaswell

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;
        }

danielballan avatar Feb 05 '24 23:02 danielballan

should probably use $server_port rather than a hard-coded port number

tacaswell avatar Feb 06 '24 18:02 tacaswell