3

I'm trying to add Guacamole (An html5 vnc client) to an existing rails project but I'm running into some trouble because the Guacamole server is implemented in Java. Based on the overview here http://guac-dev.org/doc/gug/writing-you-own-guacamole-app.html, I need to create 1. a GuacamoleHTTPTunnelServlet (a tunnel between the JavaScript client and the Guacd service) and 2. the javascript client itself. See attached picture for reference. Creating the javascript client seems easy because all the javascript is already given and I would just have to add it to a rails view. The hard part, if possible at all, is integrating the GuacamoleHTTPTunnelServlet java servlet with rails.

  1. Is there any way to have rails serve up the javascript but have the javascript communicate with a different server on the same machine? I'm guessing no because of the same origin policy.
  2. Is there any way to forward the javascript calls from rails server -> java servlet without losing performance? I'm not completely clear on how the javascript client communicates with the server but I think it's passing java objects.

I've never tried anything like this before so please excuse me for any stupidity.

enter image description here

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
stackOverlord
  • 5,342
  • 6
  • 28
  • 29
  • 1
    Did you ever build this? I would be very interested in the implementation you settled on. Please let us know how it went! – Jesse Sanford Jan 14 '16 at 05:37

1 Answers1

2

I played around with guacamole and I think your best option is to rewrite guacamole backend (that comunicates with guacd daemon) in rails. Anyway I will try to answer to your questions:

  1. You can proxy ajax requests with rack, ex:
    How do I proxy AJAX requests with Rack Middleware?

    Another way is to use a reverse proxy (nginx?), ex:
    http://yourdomain.com/your/rails/view/url
    http://yourdomain.com/guacamole

    In this manner the client (browser) will think that your applications are under the same host, avoiding the javascript same origin policy. An iframe will be a great solution.

  2. Javascript communicates with tunnel servlet that proxies requests to guacd daemon (no java objects, just a custom protocol). To speed up performances you can use a reverse proxy (answer 1, ex: nginx) instead of ruby/rack solution.

I hope this can help :)

Community
  • 1
  • 1