mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-10012: Jetty 9.4 (#2329)
* Bump Jetty to 9.4 * Use new jetty gzip handler * Redirect / to context * Update wiremock but still not working * Add session timeout configuration * server.properties.in: Change default timeout to 30 (mins) * cloudian: fix unit test failures Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * client: use older 9.2.x jetty-maven-plugin that works Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> * Moving jetty mvn plugin version in properties Signed-off-by: Marc-Aurèle Brothier <m@brothier.org> * Set default session timeout to 30mins
This commit is contained in:
parent
3eafd0ce52
commit
cd6288ecfb
@ -24,6 +24,9 @@ context.path=/client
|
||||
# The HTTP port to be used by the management server
|
||||
http.port=8080
|
||||
|
||||
# Max inactivity time in minutes for the session
|
||||
session.timeout=30
|
||||
|
||||
# Options to configure and enable HTTPS on management server
|
||||
#
|
||||
# For management server to pickup these configuration settings, the configured
|
||||
|
||||
@ -491,7 +491,7 @@
|
||||
<plugin>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-maven-plugin</artifactId>
|
||||
<version>${cs.jetty.version}</version>
|
||||
<version>${cs.jetty-maven-plugin.version}</version>
|
||||
<dependencies>
|
||||
<!-- specify the dependent jdbc driver here -->
|
||||
<dependency>
|
||||
|
||||
@ -22,13 +22,8 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.net.URL;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.servlet.DispatcherType;
|
||||
|
||||
import org.apache.commons.daemon.Daemon;
|
||||
import org.apache.commons.daemon.DaemonContext;
|
||||
import org.eclipse.jetty.jmx.MBeanContainer;
|
||||
@ -42,9 +37,9 @@ import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.ServerConnector;
|
||||
import org.eclipse.jetty.server.SslConnectionFactory;
|
||||
import org.eclipse.jetty.server.handler.HandlerCollection;
|
||||
import org.eclipse.jetty.server.handler.MovedContextHandler;
|
||||
import org.eclipse.jetty.server.handler.RequestLogHandler;
|
||||
import org.eclipse.jetty.servlet.FilterHolder;
|
||||
import org.eclipse.jetty.servlets.GzipFilter;
|
||||
import org.eclipse.jetty.server.handler.gzip.GzipHandler;
|
||||
import org.eclipse.jetty.util.ssl.SslContextFactory;
|
||||
import org.eclipse.jetty.util.thread.QueuedThreadPool;
|
||||
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
|
||||
@ -70,6 +65,7 @@ public class ServerDaemon implements Daemon {
|
||||
|
||||
private static final String BIND_INTERFACE = "bind.interface";
|
||||
private static final String CONTEXT_PATH = "context.path";
|
||||
private static final String SESSION_TIMEOUT = "session.timeout";
|
||||
private static final String HTTP_PORT = "http.port";
|
||||
private static final String HTTPS_ENABLE = "https.enable";
|
||||
private static final String HTTPS_PORT = "https.port";
|
||||
@ -86,6 +82,7 @@ public class ServerDaemon implements Daemon {
|
||||
|
||||
private int httpPort = 8080;
|
||||
private int httpsPort = 8443;
|
||||
private int sessionTimeout = 30;
|
||||
private boolean httpsEnable = false;
|
||||
private String accessLogFile = "access.log";
|
||||
private String bindInterface = "";
|
||||
@ -129,6 +126,7 @@ public class ServerDaemon implements Daemon {
|
||||
setKeystorePassword(properties.getProperty(KEYSTORE_PASSWORD));
|
||||
setWebAppLocation(properties.getProperty(WEBAPP_DIR));
|
||||
setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log"));
|
||||
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30")));
|
||||
} catch (final IOException e) {
|
||||
LOG.warn("Failed to load configuration from server.properties file", e);
|
||||
}
|
||||
@ -221,13 +219,14 @@ public class ServerDaemon implements Daemon {
|
||||
final WebAppContext webApp = new WebAppContext();
|
||||
webApp.setContextPath(contextPath);
|
||||
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
|
||||
webApp.getSessionHandler().setMaxInactiveInterval(sessionTimeout * 60);
|
||||
|
||||
final FilterHolder filter = webApp.addFilter(GzipFilter.class, "/*", EnumSet.of(DispatcherType.REQUEST));
|
||||
final Map<String, String> params = new HashMap<>();
|
||||
params.put("mimeTypes", "text/html,text/xml,text/css,text/plain,text/javascript,application/javascript,application/json,application/xml");
|
||||
params.put("methods", "GET,POST");
|
||||
params.put("deflateCompressionLevel", "9");
|
||||
filter.setInitParameters(params);
|
||||
// GZIP handler
|
||||
final GzipHandler gzipHandler = new GzipHandler();
|
||||
gzipHandler.addIncludedMimeTypes("text/html", "text/xml", "text/css", "text/plain", "text/javascript", "application/javascript", "application/json", "application/xml");
|
||||
gzipHandler.setIncludedMethods("GET", "POST");
|
||||
gzipHandler.setCompressionLevel(9);
|
||||
gzipHandler.setHandler(webApp);
|
||||
|
||||
if (Strings.isNullOrEmpty(webAppLocation)) {
|
||||
webApp.setWar(getShadedWarUrl());
|
||||
@ -235,14 +234,18 @@ public class ServerDaemon implements Daemon {
|
||||
webApp.setWar(webAppLocation);
|
||||
}
|
||||
|
||||
// Request log handler
|
||||
final RequestLogHandler log = new RequestLogHandler();
|
||||
log.setRequestLog(createRequestLog());
|
||||
|
||||
final HandlerCollection handlerCollection = new HandlerCollection();
|
||||
handlerCollection.addHandler(log);
|
||||
handlerCollection.addHandler(webApp);
|
||||
// Redirect root context handler
|
||||
MovedContextHandler rootRedirect = new MovedContextHandler();
|
||||
rootRedirect.setContextPath("/");
|
||||
rootRedirect.setNewContextURL(contextPath);
|
||||
rootRedirect.setPermanent(true);
|
||||
|
||||
return handlerCollection;
|
||||
// Put rootRedirect at the end!
|
||||
return new HandlerCollection(log, gzipHandler, rootRedirect);
|
||||
}
|
||||
|
||||
private RequestLog createRequestLog() {
|
||||
@ -307,4 +310,8 @@ public class ServerDaemon implements Daemon {
|
||||
public void setWebAppLocation(String webAppLocation) {
|
||||
this.webAppLocation = webAppLocation;
|
||||
}
|
||||
|
||||
public void setSessionTimeout(int sessionTimeout) {
|
||||
this.sessionTimeout = sessionTimeout;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.tomakehurst</groupId>
|
||||
<artifactId>wiremock</artifactId>
|
||||
<artifactId>wiremock-standalone</artifactId>
|
||||
<version>${cs.wiremock.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
5
pom.xml
5
pom.xml
@ -120,8 +120,9 @@
|
||||
<cs.cxf.version>3.2.0</cs.cxf.version>
|
||||
<cs.groovy.version>2.4.12</cs.groovy.version>
|
||||
<cs.nitro.version>10.1</cs.nitro.version>
|
||||
<cs.wiremock.version>2.8.0</cs.wiremock.version>
|
||||
<cs.jetty.version>9.2.22.v20170606</cs.jetty.version>
|
||||
<cs.wiremock.version>2.11.0</cs.wiremock.version>
|
||||
<cs.jetty.version>9.4.7.v20170914</cs.jetty.version>
|
||||
<cs.jetty-maven-plugin.version>9.2.22.v20170606</cs.jetty-maven-plugin.version>
|
||||
</properties>
|
||||
|
||||
<distributionManagement>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user