Wrap an apache application?

LabKey Support Forum (Inactive)
Wrap an apache application? Ben Bimber  2014-07-14 10:47
Status: Closed
 
I'm still exploring how to integrate LK with JBrowse (http://jbrowse.org/). JBrowse is an apache webapp for viewing sequence data. Ideally, LabKey would serve as the source/database of sequence data and files, and we could push out to JBrowse to actually visualize this information. I think I've answered most questions, but have one more:

Is there any way for labkey/tomcat to wrap or serve content from an apache server? This apache server would probably be running locally, and both apache and tomcat have access to the same filesystem. If not, is there a standard way these two might interact with one another? I ask because it would be convenient to let tomcat handle all authentication, etc.

Thanks in advance.
 
 
Matthew Bellew responded:  2014-07-14 11:40
That's a pretty interesting question. This isn't actually an answer, but this is where I would start.

1) Google for "servlet proxy" to find an existing implementation of a proxy servlet, either from Apache/Tomcat or a 3rd party.
2) Install and configure the servlet in your LabKey webapp and test (ignoring security)
3) If that works, modify/wrap the servlet to handle any LabKey specific requirements (e.g. security and/or container mapping)

This might be a good example for the community.

Matt
 
Ben Bimber responded:  2014-07-14 11:59
thanks, that's a helpful start.
 
Anthony Corbett responded:  2014-07-14 13:13
I've never set this up myself, but here are some ideas:

From the JBrowse Configuration Guide, it looks like the default index.html page that comes with JBrowse can be embedded in an iframe: http://gmod.org/wiki/JBrowse_Configuration_Guide#Embedded_mode

<div style="width: 400px; margin: 0 auto;">
  <iframe style="border: 1px solid black" src="../../index.html?data=sample_data/json/volvox&tracklist=0&nav=0&overview=0&tracks=DNA%2CExampleFeatures%2CNameTest%2CMotifs%2CAlignments%2CGenes%2CReadingFrame%2CCDS%2CTranscript%2CClones%2CEST" width="300" height="300">
  </iframe>
</div>


This would give you control of JBrowse through the query string parameters of the iframe's source URL; see http://gmod.org/wiki/JBrowse_Configuration_Guide#Controlling_JBrowse_with_the_URL_Query_String

Thus, you could create a file based module with a html view with this iframe embedded in it and all the code/queries you need to create the correct query parameters. It maybe possible to also use file-based tasks and sequences to run the perl scripts for formatting feature data and to generate pre-rendered image tracks.


The other thing is how you "push out" to JBrowse, or in other words, where is JBrowse being hosted? Here are 2 options:

One way is to have JBrowse on a completely different host from the host serving the Labkey web application (though you may or may not need to worry about cross-orgin configuration http://gmod.org/wiki/JBrowse_Configuration_Guide#Cross-origin_resource_sharing_.28CORS.29:_showing_data_on_multiple_servers)

Or, as in my group's case, if you already have Apache in front of Tomcat you might be able to use mod_rewrite/mod_alias to provide rules to serve JBrowse from the same virtual host under a different URL path than labkey; e.g. reverse proxy labkey runing at myinstance.org/labkey and then configure the virtual host to serve JBrowse at myinstance.org/jbrowse. see http://httpd.apache.org/docs/2.2/urlmapping.html By reusing the same virtual host allows you to set the iframe's src URL to src="/jbrowse/index.html?data..." and the browser will automatically insert the current domain/host.

As for authentication, JBrowse can use cookie authentication (see http://gmod.org/wiki/JBrowse_Configuration_Guide#Authentication_and_Access_Control). It might be possible to have a page in labkey set a session cookie before rendering the JBrowse in the iframe. Again, I'm not sure if modern browsers allow this type of interaction and it probably isn't the safest way to do authentication in general.

-
Anthony Corbett