Repository: incubator-zeppelin Updated Branches: refs/heads/master e4ff4c035 -> b554f9a31
Zeppelin 337 configurable context path (2) Allow to configure the context path of the webapp via zeppelin.server.context.path property or ZEPPELIN_SERVER_CONTEXT_PATH env variable + documentation for this. (replaces #385) Author: Eric Charles <[email protected]> This patch had conflicts when merged, resolved by Committer: Lee moon soo <[email protected]> Closes #429 from echarles/ZEPPELIN-337-Configurable-ContextPath and squashes the following commits: 37e07f9 [Eric Charles] Ensure context path is also setup when running with the distribution 70194fc [Eric Charles] Set /api path on servlet level, not context to fix test 54f6b07 [Eric Charles] ZEPPELIN_CONTEXT_PATH is now ZEPPELIN_SERVER_CONTEXT_PATH 9095d5d [Eric Charles] Allow to configure the context path of the webapp via zeppelin.server.context.path property or ZEPPELIN_CONTEXT_PATH env variable + add doc on this Project: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/commit/b554f9a3 Tree: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/tree/b554f9a3 Diff: http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/diff/b554f9a3 Branch: refs/heads/master Commit: b554f9a3151e820f41660b5ea0c6d55aa647bf2a Parents: e4ff4c0 Author: Eric Charles <[email protected]> Authored: Thu Nov 19 09:45:20 2015 +0100 Committer: Lee moon soo <[email protected]> Committed: Sun Nov 22 10:42:55 2015 +0900 ---------------------------------------------------------------------- conf/zeppelin-site.xml.template | 6 ++++++ docs/install/install.md | 6 ++++++ .../java/org/apache/zeppelin/server/ZeppelinServer.java | 12 ++++++------ zeppelin-web/src/components/baseUrl/baseUrl.service.js | 2 +- .../org/apache/zeppelin/conf/ZeppelinConfiguration.java | 5 +++++ 5 files changed, 24 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b554f9a3/conf/zeppelin-site.xml.template ---------------------------------------------------------------------- diff --git a/conf/zeppelin-site.xml.template b/conf/zeppelin-site.xml.template index 9098947..0f44c62 100755 --- a/conf/zeppelin-site.xml.template +++ b/conf/zeppelin-site.xml.template @@ -32,6 +32,12 @@ </property> <property> + <name>zeppelin.server.context.path</name> + <value>/</value> + <description>Context Path of the Web Application</description> +</property> + +<property> <name>zeppelin.notebook.dir</name> <value>notebook</value> <description>path or URI for notebook persist</description> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b554f9a3/docs/install/install.md ---------------------------------------------------------------------- diff --git a/docs/install/install.md b/docs/install/install.md index e1dc5d1..d391401 100644 --- a/docs/install/install.md +++ b/docs/install/install.md @@ -75,6 +75,12 @@ Configuration can be done by both environment variable(conf/zeppelin-env.sh) and <td>Allows a way to specify a ',' separated list of allowed origins for rest and websockets. i.e. http://localhost:8080</td> </tr> <tr> + <td>ZEPPELIN_SERVER_CONTEXT_PATH</td> + <td>zeppelin.server.context.path</td> + <td>/</td> + <td>Context Path of the Web Application</td> + </tr> + <tr> <td>ZEPPELIN_SSL</td> <td>zeppelin.ssl</td> <td>false</td> http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b554f9a3/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java ---------------------------------------------------------------------- diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java index 3717ecc..ea8a0b6 100644 --- a/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java +++ b/zeppelin-server/src/main/java/org/apache/zeppelin/server/ZeppelinServer.java @@ -85,7 +85,7 @@ public class ZeppelinServer extends Application { jettyServer = setupJettyServer(conf); // REST api - final ServletContextHandler restApi = setupRestApiContextHandler(); + final ServletContextHandler restApi = setupRestApiContextHandler(conf); // Notebook server final ServletContextHandler notebook = setupNotebookServer(conf); @@ -170,7 +170,7 @@ public class ZeppelinServer extends Application { ServletContextHandler.SESSIONS); cxfContext.setSessionHandler(new SessionHandler()); - cxfContext.setContextPath("/"); + cxfContext.setContextPath(conf.getServerContextPath()); cxfContext.addServlet(servletHolder, "/ws/*"); cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class)); @@ -210,7 +210,7 @@ public class ZeppelinServer extends Application { return scf.getSslContext(); } - private static ServletContextHandler setupRestApiContextHandler() { + private static ServletContextHandler setupRestApiContextHandler(ZeppelinConfiguration conf) { final ServletHolder cxfServletHolder = new ServletHolder(new CXFNonSpringJaxrsServlet()); cxfServletHolder.setInitParameter("javax.ws.rs.Application", ZeppelinServer.class.getName()); cxfServletHolder.setName("rest"); @@ -218,8 +218,8 @@ public class ZeppelinServer extends Application { final ServletContextHandler cxfContext = new ServletContextHandler(); cxfContext.setSessionHandler(new SessionHandler()); - cxfContext.setContextPath("/api"); - cxfContext.addServlet(cxfServletHolder, "/*"); + cxfContext.setContextPath(conf.getServerContextPath()); + cxfContext.addServlet(cxfServletHolder, "/api/*"); cxfContext.addFilter(new FilterHolder(CorsFilter.class), "/*", EnumSet.allOf(DispatcherType.class)); @@ -230,12 +230,12 @@ public class ZeppelinServer extends Application { ZeppelinConfiguration conf) { WebAppContext webApp = new WebAppContext(); + webApp.setContextPath(conf.getServerContextPath()); File warPath = new File(conf.getString(ConfVars.ZEPPELIN_WAR)); if (warPath.isDirectory()) { // Development mode, read from FS // webApp.setDescriptor(warPath+"/WEB-INF/web.xml"); webApp.setResourceBase(warPath.getPath()); - webApp.setContextPath("/"); webApp.setParentLoaderPriority(true); } else { // use packaged WAR http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b554f9a3/zeppelin-web/src/components/baseUrl/baseUrl.service.js ---------------------------------------------------------------------- diff --git a/zeppelin-web/src/components/baseUrl/baseUrl.service.js b/zeppelin-web/src/components/baseUrl/baseUrl.service.js index f5eb2df..f06eef3 100644 --- a/zeppelin-web/src/components/baseUrl/baseUrl.service.js +++ b/zeppelin-web/src/components/baseUrl/baseUrl.service.js @@ -32,7 +32,7 @@ angular.module('zeppelinWebApp').service('baseUrlSrv', function() { this.getWebsocketUrl = function() { var wsProtocol = location.protocol === 'https:' ? 'wss:' : 'ws:'; - return wsProtocol + '//' + location.hostname + ':' + this.getPort() + '/ws'; + return wsProtocol + '//' + location.hostname + ':' + this.getPort() + skipTrailingSlash(location.pathname) + '/ws'; }; this.getRestApiBase = function() { http://git-wip-us.apache.org/repos/asf/incubator-zeppelin/blob/b554f9a3/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java ---------------------------------------------------------------------- diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java index 19ddceb..1796430 100755 --- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java +++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/conf/ZeppelinConfiguration.java @@ -268,6 +268,10 @@ public class ZeppelinConfiguration extends XMLConfiguration { return getInt(ConfVars.ZEPPELIN_PORT); } + public String getServerContextPath() { + return getString(ConfVars.ZEPPELIN_SERVER_CONTEXT_PATH); + } + public String getKeyStorePath() { return getRelativeDir( String.format("%s/%s", @@ -383,6 +387,7 @@ public class ZeppelinConfiguration extends XMLConfiguration { ZEPPELIN_HOME("zeppelin.home", "../"), ZEPPELIN_ADDR("zeppelin.server.addr", "0.0.0.0"), ZEPPELIN_PORT("zeppelin.server.port", 8080), + ZEPPELIN_SERVER_CONTEXT_PATH("zeppelin.server.context.path", "/"), ZEPPELIN_SSL("zeppelin.ssl", false), ZEPPELIN_SSL_CLIENT_AUTH("zeppelin.ssl.client.auth", false), ZEPPELIN_SSL_KEYSTORE_PATH("zeppelin.ssl.keystore.path", "keystore"),
