Skip to content

Instantly share code, notes, and snippets.

@serac
Created May 2, 2013 19:21
Show Gist options
  • Select an option

  • Save serac/5504668 to your computer and use it in GitHub Desktop.

Select an option

Save serac/5504668 to your computer and use it in GitHub Desktop.
Sample Monolithic Jetty Configuration
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
<Configure id="Server" class="org.eclipse.jetty.server.Server">
<!-- =========================================================== -->
<!-- Configure STDERR/STDOUT logging -->
<!-- =========================================================== -->
<New id="ServerLog" class="java.io.PrintStream">
<Arg>
<New class="edu.vt.middleware.io.RollingFileOutputStream">
<Arg><Property name="jetty.logs" default="./logs"/>/stderrout.log</Arg>
<!-- Maximum size of each file -->
<Arg>1M</Arg>
<!-- Append to existing file -->
<Arg type="boolean">true</Arg>
<!-- Number of backups. Total number of files is maxBackups + 1. -->
<Set name="maxBackups">10</Set>
<Get id="ServerLogName" name="outputFile"/>
</New>
</Arg>
</New>
<Call class="org.eclipse.jetty.util.log.Log" name="info"><Arg>Redirecting stderr/stdout to <Ref id="ServerLogName"/></Arg></Call>
<Call class="java.lang.System" name="setErr"><Arg><Ref id="ServerLog"/></Arg></Call>
<Call class="java.lang.System" name="setOut"><Arg><Ref id="ServerLog"/></Arg></Call>
<!-- Remove start.log once we have configured STDERR/STDOUT redirection -->
<Call class="edu.vt.middleware.io.FileDeleter" name="delete">
<Arg>
<New class="java.io.File">
<Arg><Property name="jetty.logs" default="./logs"/></Arg>
</New>
</Arg>
<Arg>
<New class="org.apache.commons.io.filefilter.RegexFileFilter">
<Arg>.*\.start\.log</Arg>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Server Thread Pool -->
<!-- =========================================================== -->
<Set name="ThreadPool">
<!-- Default queued blocking threadpool -->
<New class="org.eclipse.jetty.util.thread.QueuedThreadPool">
<Set name="minThreads">10</Set>
<Set name="maxThreads">200</Set>
<Set name="detailedDump">false</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Set connectors -->
<!-- =========================================================== -->
<Call name="addConnector">
<!-- Plain HTTP connector -->
<Arg>
<New class="org.eclipse.jetty.server.nio.SelectChannelConnector">
<Set name="host"><Property name="jetty.host" /></Set>
<Set name="port"><Property name="jetty.port" default="8080"/></Set>
<Set name="maxIdleTime">300000</Set>
<Set name="Acceptors">2</Set>
<Set name="statsOn">false</Set>
<Set name="confidentialPort">8443</Set>
<Set name="lowResourcesConnections">20000</Set>
<Set name="lowResourcesMaxIdleTime">5000</Set>
</New>
</Arg>
</Call>
<Array id="cipherSuites" type="java.lang.String">
<Item>TLS_ECDHE_RSA_WITH_RC4_128_SHA</Item>
<Item>TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_DHE_RSA_WITH_AES_128_CBC_SHA</Item>
<Item>TLS_DHE_DSS_WITH_AES_128_CBC_SHA</Item>
<Item>SSL_RSA_WITH_RC4_128_SHA</Item>
<Item>SSL_RSA_WITH_RC4_128_MD5</Item>
<Item>SSL_RSA_WITH_3DES_EDE_CBC_SHA</Item>
<Item>SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA</Item>
<Item>SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA</Item>
</Array>
<Call name="addConnector">
<!-- HTTPS connector -->
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Arg>
<New id="sslContextFactory" class="org.eclipse.jetty.http.ssl.SslContextFactory">
<Set name="KeyStore"><Property name="jetty.keystore.path"/></Set>
<Set name="KeyStoreType"><Property name="jetty.keystore.type"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.keystore.pass"/></Set>
<Set name="TrustStore"><Property name="jetty.truststore.path"/></Set>
<Set name="TrustStoreType"><Property name="jetty.truststore.type"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.truststore.pass"/></Set>
<Set name="IncludeCipherSuites">
<Ref id="cipherSuites" />
</Set>
</New>
</Arg>
<Set name="Host"><Property name="jetty.host"/></Set>
<Set name="Port"><Property name="jetty.port.ssl"/></Set>
<Set name="MaxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="AcceptQueueSize">100</Set>
</New>
</Arg>
</Call>
<Call name="addConnector">
<!-- HTTPS connector with optional client SSL -->
<Arg>
<New class="org.eclipse.jetty.server.ssl.SslSelectChannelConnector">
<Arg>
<New id="clientSSLContextFactory" class="org.eclipse.jetty.http.ssl.SslContextFactory">
<Set name="KeyStore"><Property name="jetty.keystore.path"/></Set>
<Set name="KeyStoreType"><Property name="jetty.keystore.type"/></Set>
<Set name="KeyStorePassword"><Property name="jetty.keystore.pass"/></Set>
<Set name="TrustStore"><Property name="jetty.truststore.path"/></Set>
<Set name="TrustStoreType"><Property name="jetty.truststore.type"/></Set>
<Set name="TrustStorePassword"><Property name="jetty.truststore.pass"/></Set>
<Set name="IncludeCipherSuites">
<Ref id="cipherSuites" />
</Set>
<Set name="WantClientAuth">true</Set>
</New>
</Arg>
<Set name="Host"><Property name="jetty.host"/></Set>
<Set name="Port"><Property name="jetty.port.client-ssl"/></Set>
<Set name="MaxIdleTime">30000</Set>
<Set name="Acceptors">2</Set>
<Set name="AcceptQueueSize">100</Set>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Set handler Collection Structure -->
<!-- =========================================================== -->
<Set name="handler">
<New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
<Set name="handlers">
<Array type="org.eclipse.jetty.server.Handler">
<Item>
<New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
</Item>
<Item>
<New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
</Item>
<Item>
<New id="StatsHandler" class="org.eclipse.jetty.server.handler.StatisticsHandler" />
</Item>
<Item>
<New id="RequestLogHandler" class="org.eclipse.jetty.server.handler.RequestLogHandler">
<Set name="requestLog">
<New class="org.eclipse.jetty.server.NCSARequestLog">
<Set name="filename"><Property name="jetty.logs" default="./logs"/>/request.yyyy_mm_dd.log</Set>
<Set name="filenameDateFormat">yyyy_MM_dd</Set>
<Set name="retainDays">90</Set>
<Set name="append">true</Set>
<Set name="extended">false</Set>
<Set name="logCookies">false</Set>
<Set name="LogTimeZone">GMT</Set>
</New>
</Set>
</New>
</Item>
</Array>
</Set>
</New>
</Set>
<!-- =========================================================== -->
<!-- Configure deployment managers -->
<!-- =========================================================== -->
<Call name="addBean">
<Arg>
<New id="DeploymentManager" class="org.eclipse.jetty.deploy.DeploymentManager">
<Set name="contexts">
<Ref id="Contexts" />
</Set>
<Call name="setContextAttribute">
<Arg>org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern</Arg>
<Arg>.*/servlet-api-[^/]*\.jar$</Arg>
</Call>
<Call name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.WebAppProvider">
<Set name="monitoredDirName"><Property name="jetty.webapps" default="./webapps" /></Set>
<Set name="defaultsDescriptor"><Property name="jetty.home" default="."/>/etc/webdefault.xml</Set>
<Set name="scanInterval">10</Set>
<Set name="contextXmlDir"><Property name="jetty.contexts" default="./contexts" /></Set>
<Set name="extractWars">true</Set>
</New>
</Arg>
</Call>
<Call name="addAppProvider">
<Arg>
<New class="org.eclipse.jetty.deploy.providers.ContextProvider">
<Set name="monitoredDirName"><Property name="jetty.contexts" default="./contexts" /></Set>
<Set name="scanInterval">10</Set>
<Set name="configurationManager">
<New class="org.eclipse.jetty.deploy.FileConfigurationManager">
<!-- Should be the path to a properties file with environment-specific properties for all contexts. -->
<Set name="file"><SystemProperty name="jetty.environment"/></Set>
</New>
</Set>
</New>
</Arg>
</Call>
</New>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Configure deployment steps for every web app -->
<!-- =========================================================== -->
<Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.configuration</Arg>
<Arg>
<Array type="java.lang.String">
<Item>org.eclipse.jetty.webapp.WebInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.WebXmlConfiguration</Item>
<Item>org.eclipse.jetty.webapp.MetaInfConfiguration</Item>
<Item>org.eclipse.jetty.webapp.FragmentConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.EnvConfiguration</Item>
<Item>org.eclipse.jetty.plus.webapp.PlusConfiguration</Item>
<Item>org.eclipse.jetty.annotations.AnnotationConfiguration</Item>
<Item>org.eclipse.jetty.webapp.JettyWebXmlConfiguration</Item>
</Array>
</Arg>
</Call>
<!-- =========================================================== -->
<!-- Extra options -->
<!-- =========================================================== -->
<Set name="stopAtShutdown">true</Set>
<Set name="sendServerVersion">true</Set>
<Set name="sendDateHeader">true</Set>
<Set name="gracefulShutdown">1000</Set>
<Set name="dumpAfterStart">false</Set>
<Set name="dumpBeforeStop">false</Set>
</Configure>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment