From 769a1a2d0b689e7490f8a045284232e8d75477b1 Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Fri, 23 Sep 2022 17:18:54 +0200 Subject: [PATCH 1/4] Making sure only one slash in start of interactive tool entry point path --- lib/galaxy/managers/interactivetool.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/galaxy/managers/interactivetool.py b/lib/galaxy/managers/interactivetool.py index 971d2bb5f41..3b3849c5e6e 100644 --- a/lib/galaxy/managers/interactivetool.py +++ b/lib/galaxy/managers/interactivetool.py @@ -319,8 +319,7 @@ class InteractiveToolManager: rval = f"/{rval}/{entry_point_prefix}/access/{entry_point_class}/{entry_point_encoded_id}/{entry_point.token}/" if entry_point.entry_url: rval = f"{rval.rstrip('/')}/{entry_point.entry_url.lstrip('/')}" - if rval[0] != "/": - rval = f"/{rval}" + rval = '/' + rval.lstrip('/') return rval def access_entry_point_target(self, trans, entry_point_id): From 89bf7b1e5216f278c2e6f4930050e2b696695cbc Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Fri, 23 Sep 2022 17:19:31 +0200 Subject: [PATCH 2/4] Adding documentation and example nginx config to allow path-based interactive tools --- .../admin/special_topics/interactivetools.rst | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/doc/source/admin/special_topics/interactivetools.rst b/doc/source/admin/special_topics/interactivetools.rst index 69e65cb8478..22a8b48cffe 100644 --- a/doc/source/admin/special_topics/interactivetools.rst +++ b/doc/source/admin/special_topics/interactivetools.rst @@ -77,7 +77,8 @@ Set these values in `galaxy.yml`: # ... -If you do want to use nginx as an upstream proxy server you can use the following server section to route requests to the InteractiveTool proxy: +If you do want to use nginx as an upstream proxy server you can use the following server section to route requests to +the InteractiveTool proxy: .. code-block:: nginx @@ -87,7 +88,7 @@ If you do want to use nginx as an upstream proxy server you can use the followin # Match all requests for the interactive tools subdomain server_name *.interactivetool.localhost; - # Proxy all requests to the GIE Proxy application + # Route all domain-based interactive tool requests to the InteractiveTool proxy application location / { proxy_redirect off; proxy_http_version 1.1; @@ -101,8 +102,28 @@ If you do want to use nginx as an upstream proxy server you can use the followin Note that this nginx example uses https, so you need to have a wildcard certificate for your domain, -and you need to adjust ``galaxy_infrastructure_url`` as appropriate. You will most likely also want -to replace localhost with your server domain. +and you need to adjust ``galaxy_infrastructure_url`` as appropriate. + +It is also possible to set up nginx to route path-based interactive tool URLs to the InteractiveTool proxy. +Path-based interactive tool URLs will only be created for tools that have defined ``requires_domain=False`` in the tool +XML file (which signals that the web server running on the container does not require a domain name to serve pages +correctly). To support path-based interactive tools through nginx proxy, add the following to the main Galaxy "server" +section (serving port 443): + +.. code-block:: nginx + + # Route all path-based interactive tool requests to the InteractiveTool proxy application + location ~* ^/(interactivetool)/access/(.+)/([0-9a-f]+)/([0-9a-f]+)/(.*)$ { + proxy_redirect off; + proxy_http_version 1.1; + proxy_set_header Host $3-$4.$1.$host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_pass http://localhost:4002/$5$is_args$args; + } + +In both cases, you will most likely also want to replace localhost with your server domain (or possibly ``127.0.0.1``). You will also need to enable a docker destination in the job_conf.xml file. An example ``job_conf.xml`` file as seen in ``config/job_conf.xml.interactivetools``: From 4ec8c4654e4bb3bc02a619d4c424d476b46a55a7 Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Fri, 23 Sep 2022 17:54:01 +0200 Subject: [PATCH 3/4] Added info on galaxy.yml config --- doc/source/admin/special_topics/interactivetools.rst | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/doc/source/admin/special_topics/interactivetools.rst b/doc/source/admin/special_topics/interactivetools.rst index 22a8b48cffe..2e7a3199913 100644 --- a/doc/source/admin/special_topics/interactivetools.rst +++ b/doc/source/admin/special_topics/interactivetools.rst @@ -123,7 +123,12 @@ section (serving port 443): proxy_pass http://localhost:4002/$5$is_args$args; } -In both cases, you will most likely also want to replace localhost with your server domain (or possibly ``127.0.0.1``). +This example config works for default values of `interactivetools_base_path` and `interactivetools_prefix` as defined in +`galaxy.yml`. For other values, you will need to adjust the regex and rename patterns accordingly. This solution also +requires `interactivetools_shorten_url` to be set to `false` (not default). + +In both nginx config examples, you will most likely also want to replace localhost with your server domain (or possibly +``127.0.0.1``). You will also need to enable a docker destination in the job_conf.xml file. An example ``job_conf.xml`` file as seen in ``config/job_conf.xml.interactivetools``: From afca8f3ba8b2c8721bc3cda8da506c7e67761b63 Mon Sep 17 00:00:00 2001 From: Sveinung Gundersen Date: Fri, 23 Sep 2022 17:55:13 +0200 Subject: [PATCH 4/4] Fixed linting --- lib/galaxy/managers/interactivetool.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/galaxy/managers/interactivetool.py b/lib/galaxy/managers/interactivetool.py index 3b3849c5e6e..d091c4fd862 100644 --- a/lib/galaxy/managers/interactivetool.py +++ b/lib/galaxy/managers/interactivetool.py @@ -319,7 +319,7 @@ class InteractiveToolManager: rval = f"/{rval}/{entry_point_prefix}/access/{entry_point_class}/{entry_point_encoded_id}/{entry_point.token}/" if entry_point.entry_url: rval = f"{rval.rstrip('/')}/{entry_point.entry_url.lstrip('/')}" - rval = '/' + rval.lstrip('/') + rval = "/" + rval.lstrip("/") return rval def access_entry_point_target(self, trans, entry_point_id):