Skip to content

Tomcat Configuration in Martini

In the Martini Server Runtime, Tomcat configuration involves setting up and fine-tuning various properties to control the behavior of the embedded Tomcat server. Martini Server Runtime includes Apache Tomcat for serving all HTTP requests. To optimize its performance, you can tune the Tomcat settings.

Properties related to Tomcat can be adjusted using the Martini Server Runtime application properties, however it is recommended to make any changes in the override.properties file located at <martini-home>/conf/.

Tomcat engine properties

See document for more information: The Engine Container.

  • Engine startStopThreads: The number of threads the Tomcat engine will use to start child host elements in parallel.

    1
    server.tomcat.engine.startStopThreads=1
    

Tomcat host properties

See document for more information: The Host Container.

  • Host startStopThreads: The number of threads this host will use to start child context elements in parallel.

    1
    server.tomcat.host.startStopThreads=1
    

Tomcat HTTP/S properties

Supported attributes are documented here: The HTTP Connector.

  • Compression: Set to "on" by default to use HTTP/1.1 GZIP compression on response payloads in an attempt to save server bandwidth. The acceptable values for the parameter is off (disable compression), on (allow compression, which causes text data to be compressed), "force" (forces compression in all cases), or a numerical integer value (which is equivalent to "on", but specifies the minimum amount of data before the output is compressed). If the content-length is not known and compression is set to "on" or more aggressive, the output will also be compressed. If not specified, this attribute is set to "off".

    1
    2
    server.tomcat.http.compression=on
    server.tomcat.https.compression=on
    
  • Max Threads: The maximum number of request processing threads to be created by the connector, which therefore determines the maximum number of simultaneous requests that can be handled.

    1
    2
    server.tomcat.http.maxThreads=200
    server.tomcat.https.maxThreads=200
    
  • Protocol: Sets the protocol to handle incoming traffic.

    1
    2
    server.tomcat.http.protocol=org.apache.coyote.http11.Http11AprProtocol
    server.tomcat.https.protocol=org.apache.coyote.http11.Http11AprProtocol
    
  • Proxy Port: If this connector is being used in a proxy configuration, configure this attribute to specify the server port to be returned for calls to request.getServerPort().

    1
    2
    server.tomcat.http.proxyPort=-1
    server.tomcat.https.proxyPort=-1
    
  • Relaxed Path Characters: Additional characters in URI paths to be allowed by Tomcat in unencoded form. The value may be a combination of any of the following characters: " < > [ \ ] ^ ` { | }. Any other characters present in the value will be ignored.

    1
    2
    server.tomcat.http.relaxedPathChars=[]|
    server.tomcat.https.relaxedPathChars=[]|
    
  • Relaxed Query Characters: Additional characters in URI query strings to be allowed by Tomcat in unencoded form. The value may be a combination of any of the following characters " < > [ \ ] ^ ` { | } . Any other characters present in the value will be ignored.

    1
    2
    server.tomcat.http.relaxedQueryChars=[]|{}^&#x5c;&#x60;&quot;&lt;&gt;
    server.tomcat.https.relaxedQueryChars=[]|{}^&#x5c;&#x60;&quot;&lt;&gt;
    
  • Server Name: The value for this attribute overrides any Server header set by a web application. If not set, any value specified by the application is used. If the application does not specify a value then no Server header is set.

    1
    2
    server.tomcat.http.server-name=Martini Runtime
    server.tomcat.https.server-name=Martini Runtime
    
  • SSL Protocol: The SSL protocol(s) to use (a single value may enable multiple protocols).

    1
    server.tomcat.https.sslProtocol=TLSv1+TLSv1.1+TLSv1.2
    

Tomcat RemoteIpValve properties

Read more about the RemoteIpValve class here: Class RemoteIpValve.

  • RemoteIpValve Enabled: Indicates whether or not to use a RemoteIpValve.

    1
    server.tomcat.valve.remote-ip-valve.enabled=false
    
  • RemoteIpValve Internal Proxy: Regular expression that a proxy's IP address must match to be considered an internal proxy.

    1
    server.tomcat.valve.remote-ip-valve.internalProxies=10\.\d{1,3}\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3}| 169\.254\.\d{1,3}\.\d{1,3}|127\.\d{1,3}\.\d{1,3}\.\d{1,3}| 172\.1[6-9]{1}\.\d{1,3}\.\d{1,3}|172\.2[0-9]{1}\.\d{1,3}\.\d{1,3}| 172\.3[0-1]{1}\.\d{1,3}\.\d{1,3}| 0:0:0:0:0:0:0:1|::1
    
  • RemoteIpValve Proxies Header: Name of the HTTP header created by this valve to hold the list of proxies that have been processed in the incoming remoteIpHeader.

    1
    server.tomcat.valve.remote-ip-valve.proxiesHeader=x-forwarded-by
    
  • RemoteIpValve Remote IP Header: Name of the HTTP header read by this valve that holds the list of traversed IP addresses starting from the requesting client.

    1
    server.tomcat.valve.remote-ip-valve.remoteIpHeader=x-forwarded-for
    
  • RemoteIpValve Trusted Proxies: Regular expression that a proxy's IP address must match to be considered an trusted proxy.

    1
    server.tomcat.valve.remote-ip-valve.trustedProxies=
    
  • RemoteIpValve Request Attributes Enabled: Set to true to set the request attributes used by AccessLog implementations to override the values returned by the request for remote address, remote host, server port and protocol. Request attributes are also used to enable the forwarded remote address to be displayed on the status page of the Manager web application. If not set, the default value of true will be used.

    1
    server.tomcat.valve.remote-ip-valve.requestAttributesEnabled=true
    

StuckThreadDetectionValve properties

See document for more information: Class StuckThreadDetectionValve.

  • Stuck Thread Valve Threshold: The threshold seconds where martini will declare your servlet request as stuck. Specifies the threshold (in seconds) used when checking for stuck threads. If <=0, the detection is disabled. The default is 600 seconds.

    1
    server.tomcat.valve.stuck-thread-valve.threshold=600
    
  • Stuck Thread Valve Interrupt Threshold: Set if you want to interrupt the stuck threads. Specifies the threshold (in seconds) before stuck threads are interrupted. If <=0, the interruption is disabled. The default is -1. If >=0, the value must actually be >= threshold.

    1
    server.tomcat.valve.stuck-thread-valve.interruptThreshold=-1