Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions client/conf/server.properties.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ http.port=8080
# Max inactivity time in minutes for the session
session.timeout=30

# Max allowed API request payload / content size in bytes
request.content.size=1048576

# Options to configure and enable HTTPS on management server
#
# For management server to pickup these configuration settings, the configured
Expand Down
19 changes: 15 additions & 4 deletions client/src/main/java/org/apache/cloudstack/ServerDaemon.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import java.net.URL;
import java.util.Properties;

import com.cloud.utils.Pair;
import com.cloud.utils.server.ServerProperties;
import org.apache.commons.daemon.Daemon;
import org.apache.commons.daemon.DaemonContext;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.server.ForwardedRequestCustomizer;
import org.eclipse.jetty.server.HttpConfiguration;
Expand All @@ -40,6 +40,7 @@
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.SslConnectionFactory;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.HandlerCollection;
import org.eclipse.jetty.server.handler.MovedContextHandler;
import org.eclipse.jetty.server.handler.RequestLogHandler;
Expand All @@ -50,10 +51,10 @@
import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.util.thread.ScheduledExecutorScheduler;
import org.eclipse.jetty.webapp.WebAppContext;
import org.apache.log4j.Logger;

import com.cloud.utils.Pair;
import com.cloud.utils.PropertiesUtil;
import org.apache.commons.lang3.StringUtils;
import com.cloud.utils.server.ServerProperties;

/***
* The ServerDaemon class implements the embedded server, it can be started either
Expand All @@ -79,6 +80,8 @@ public class ServerDaemon implements Daemon {
private static final String KEYSTORE_PASSWORD = "https.keystore.password";
private static final String WEBAPP_DIR = "webapp.dir";
private static final String ACCESS_LOG = "access.log";
private static final String REQUEST_CONTENT_SIZE_KEY = "request.content.size";
private static final int DEFAULT_REQUEST_CONTENT_SIZE = 1048576;

////////////////////////////////////////////////////////
/////////////// Server Configuration ///////////////////
Expand All @@ -90,6 +93,7 @@ public class ServerDaemon implements Daemon {
private int httpPort = 8080;
private int httpsPort = 8443;
private int sessionTimeout = 30;
private int maxFormContentSize = DEFAULT_REQUEST_CONTENT_SIZE;
private boolean httpsEnable = false;
private String accessLogFile = "access.log";
private String bindInterface = null;
Expand Down Expand Up @@ -136,6 +140,7 @@ public void init(final DaemonContext context) {
setWebAppLocation(properties.getProperty(WEBAPP_DIR));
setAccessLogFile(properties.getProperty(ACCESS_LOG, "access.log"));
setSessionTimeout(Integer.valueOf(properties.getProperty(SESSION_TIMEOUT, "30")));
setMaxFormContentSize(Integer.valueOf(properties.getProperty(REQUEST_CONTENT_SIZE_KEY, String.valueOf(DEFAULT_REQUEST_CONTENT_SIZE))));
} catch (final IOException e) {
LOG.warn("Failed to read configuration from server.properties file", e);
} finally {
Expand Down Expand Up @@ -186,6 +191,7 @@ public void start() throws Exception {

// Extra config options
server.setStopAtShutdown(true);
server.setAttribute(ContextHandler.MAX_FORM_CONTENT_SIZE_KEY, maxFormContentSize);

// HTTPS Connector
createHttpsConnector(httpConfig);
Expand Down Expand Up @@ -257,6 +263,7 @@ private Pair<SessionHandler,HandlerCollection> createHandlers() {
final WebAppContext webApp = new WebAppContext();
webApp.setContextPath(contextPath);
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
webApp.setMaxFormContentSize(maxFormContentSize);

// GZIP handler
final GzipHandler gzipHandler = new GzipHandler();
Expand Down Expand Up @@ -355,4 +362,8 @@ public void setWebAppLocation(String webAppLocation) {
public void setSessionTimeout(int sessionTimeout) {
this.sessionTimeout = sessionTimeout;
}

public void setMaxFormContentSize(int maxFormContentSize) {
this.maxFormContentSize = maxFormContentSize;
}
}