updated the base url handler to extract any app prefix from the absUrl in case onos is behind an app prefix

Change-Id: I271da533f39091efdd01d8104c1e6740effead52
(cherry picked from commit 3faa011)
diff --git a/web/gui/src/main/webapp/app/fw/remote/urlfn.js b/web/gui/src/main/webapp/app/fw/remote/urlfn.js
index 3ea02b4..03ae09e 100644
--- a/web/gui/src/main/webapp/app/fw/remote/urlfn.js
+++ b/web/gui/src/main/webapp/app/fw/remote/urlfn.js
@@ -34,8 +34,19 @@
             }
 
             function urlBase(protocol, port, host) {
+                // A little bit of funky here. It is possible that ONOS sits behind a proxy
+                // and has an app prefix, e.g. http://host:port/my/app/onos/ui... This bit
+                // of regex grabs everything after the host:port and before the uiContext
+                // (/onos/ui/) and uses that as an app prefix by inserting it back into
+                // the WS URL, if no prefix, then no insert.
+                var prefix = ""
+                if ($loc.absUrl) {
+                    var p = $loc.absUrl().match(".*//[^/]+/(.+)"+uiContext);
+                    prefix = p ? '/' + p[1] : '';
+                }
+
                 return matchSecure(protocol) + '://' +
-                    (host || $loc.host()) + ':' + (port || $loc.port());
+                    (host || $loc.host()) + ':' + (port || $loc.port()) + prefix;
             }
 
             function httpPrefix(suffix) {