openanalytics / shinyproxy

ShinyProxy - Open Source Enterprise Deployment for Shiny and data science apps
https://www.shinyproxy.io
Apache License 2.0
525 stars 151 forks source link

Example of using external-url #491

Closed danielloader closed 5 months ago

danielloader commented 6 months ago

Excitedly been watching the released notifications for 3.1.0 and this feature has turned up, but I don't know how to use it, so a simple example would be appreciated!

Thanks

LEDfan commented 6 months ago

Hi, I just added an example to the documentation: https://shinyproxy.io/documentation/configuration/#external-url Hope this helps!

danielloader commented 6 months ago

I've tried this and I get this error:

image

eu.openanalytics.containerproxy.ProxyFailedToStartException: Container failed to start
    at eu.openanalytics.containerproxy.service.ProxyService.prepareProxyForStart(ProxyService.java:458) ~[containerproxy-1.1.0.jar!/:1.1.0]
    at eu.openanalytics.containerproxy.service.ProxyService.startOrResumeProxy(ProxyService.java:466)
    at eu.openanalytics.containerproxy.service.ProxyService.lambda$startProxy$7(ProxyService.java:293)
    at eu.openanalytics.containerproxy.service.ProxyService.lambda$action$14(ProxyService.java:638)
    ... 5 frames excluded
Caused by: java.lang.IllegalStateException: This is an external app and cannot be started
    at eu.openanalytics.shinyproxy.external.ExternalAppSpecExtension.firstResolve(ExternalAppSpecExtension.java:49) ~[!/:3.1.0]
    at eu.openanalytics.shinyproxy.external.ExternalAppSpecExtension.firstResolve(ExternalAppSpecExtension.java:35)
    at eu.openanalytics.containerproxy.model.spec.ProxySpec.lambda$firstResolve$0(ProxySpec.java:135) ~[containerproxy-1.1.0.jar!/:1.1.0]
    at java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180) ~[na:na]
    at java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    at java.util.HashMap$EntrySpliterator.forEachRemaining(HashMap.java:1850)
    at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at eu.openanalytics.containerproxy.model.spec.ProxySpec.firstResolve(ProxySpec.java:133) ~[containerproxy-1.1.0.jar!/:1.1.0]
    at eu.openanalytics.containerproxy.service.ProxyService.prepareProxyForStart(ProxyService.java:433)
    ... 8 common frames omitted

With the relevant config:

proxy:
  specs:
    - id: basic-external-url
      display-name: Basic External URL
      description: Example description
      external-url: https://shinyproxy.io
      access-groups:
        - admins

Thanks for any help you can provide.

Can cross-link this over to the shinyproxy repository if this is a bug that needs fixing.

LEDfan commented 6 months ago

Thanks for your additional testing, are you perhaps using custom templates? The idea of the external url feature is that the link on the main page redirects the user to the external url. In order for this to work, you'll need to use the templates that come with ShinyProxy 3.1.0.

If you open the app url of the external app, you'll indeed get an error, because there is no way to start an external app. But maybe it makes sense here to also redirect the user to the external URL.

danielloader commented 6 months ago

Edit: You were correct the custom template was the issue!

So it's not expected to embed it inside the iframe/application, it's just a static link that the browser goes to wholesale?

A shim to a url "as an app" would be quite beneficial in a kubernetes context, if you had a bunch of R/Shiny apps that needed to have pods launched but you also want to embed some more traditional applications that are already deployed you could have an entry to 'service-name.namespace:8080' and it's pretty seamless to the user.

At that point it allows for a cohesive experience using R applications where you're expecting a pod launch per user session, and something more traditional hitting a horizontally scaled replica deployment.

I know you can (and we do) launch other arbitrary web apps via shinyproxy, just musing aloud about effectively allowing one of your apps/navbar items being a very simple reverse proxy implemented by shinyproxy, so that the Oauth2 flow can be retained as a single session across the domain serving the web traffic.

LEDfan commented 5 months ago

Hi, we just released ShinyProxy 3.1.1, when you now visit the page of an app that is using the external-url property, you'll be redirected to this url. So this will not yet include the app as an iframe or proxy the app. If you still find this important, feel free to open a new issue for this.