CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/maven-org-springframework-boot--spring-boot-starter-tomcat

Starter for using Tomcat as the embedded servlet container, providing default servlet container functionality for Spring Boot web applications

Pending
Overview
Eval results
Files

configuration-properties.mddocs/

Configuration Properties

Comprehensive configuration options through Spring Boot's properties system, covering connection settings, threading, access logging, static resources, SSL, and performance tuning. These properties provide declarative configuration without requiring custom code.

Capabilities

ServerProperties.Tomcat

Main configuration class for all Tomcat-specific properties under the server.tomcat.* prefix.

/**
 * Tomcat-specific server properties configuration
 */
@ConfigurationProperties(prefix = "server.tomcat")
public static class Tomcat {
    
    /** Tomcat base directory for temporary files and work directories */
    private File basedir;
    
    /** Background processor delay for maintenance tasks (default: 10s) */
    private Duration backgroundProcessorDelay = Duration.ofSeconds(10);
    
    /** Maximum number of connections server will accept and process (default: 8192) */  
    private int maxConnections = 8192;
    
    /** Maximum queue length for incoming connections (default: 100) */
    private int acceptCount = 100;
    
    /** Processor cache size for request processing (default: 200) */
    private int processorCache = 200;
    
    /** Connection timeout for client connections */
    private Duration connectionTimeout;
    
    /** Keep-alive timeout for persistent connections */ 
    private Duration keepAliveTimeout;
    
    /** Maximum number of HTTP requests per keep-alive connection (default: 100) */
    private int maxKeepAliveRequests = 100;
    
    /** Maximum size of HTTP form post data (default: 2MB) */
    private DataSize maxHttpFormPostSize = DataSize.ofMegabytes(2);
    
    /** Maximum size of request data to swallow (default: 2MB) */
    private DataSize maxSwallowSize = DataSize.ofMegabytes(2);
    
    /** Character encoding for URI decoding (default: UTF-8) */
    private Charset uriEncoding = StandardCharsets.UTF_8;
    
    /** Characters allowed in URL paths beyond standard safe characters */
    private List<Character> relaxedPathChars = new ArrayList<>();
    
    /** Characters allowed in URL query strings beyond standard safe characters */
    private List<Character> relaxedQueryChars = new ArrayList<>();
    
    /** Whether to redirect requests with context root (default: true) */
    private Boolean redirectContextRoot = true;
    
    /** Whether to use relative redirects (default: false) */
    private boolean useRelativeRedirects = false;
    
    /** Additional patterns for TLD files to skip during scanning */
    private List<String> additionalTldSkipPatterns = new ArrayList<>();
    
    /** Thread pool configuration */
    private final Threads threads = new Threads();
    
    /** Access log configuration */
    private final Accesslog accesslog = new Accesslog();
    
    /** Static resource configuration */
    private final Resource resource = new Resource();
    
    /** MBean registry configuration */
    private final Mbeanregistry mbeanregistry = new Mbeanregistry();
    
    /** Remote IP valve configuration */
    private final Remoteip remoteip = new Remoteip();
}

Thread Configuration

Configuration for Tomcat's thread pool under server.tomcat.threads.* prefix.

/**
 * Thread pool configuration for Tomcat connectors
 */
public static class Threads {
    
    /** Maximum number of worker threads (default: 200) */
    private int max = 200;
    
    /** Minimum number of spare worker threads (default: 10) */
    private int minSpare = 10;
}

Configuration Example:

server.tomcat.threads.max=300
server.tomcat.threads.min-spare=20

Access Log Configuration

Configuration for Tomcat access logging under server.tomcat.accesslog.* prefix.

/**
 * Access log configuration for request logging
 */
public static class Accesslog {
    
    /** Whether to enable access logging (default: false) */
    private boolean enabled = false;
    
    /** Access log pattern format (default: "common") */
    private String pattern = "common";
    
    /** Directory for access log files (default: "logs") */
    private String directory = "logs";
    
    /** Prefix for access log file names (default: "access_log") */
    private String prefix = "access_log";
    
    /** Suffix for access log file names (default: ".log") */
    private String suffix = ".log";
    
    /** Character encoding for log files */
    private String encoding;
    
    /** Whether to rotate log files daily (default: true) */
    private boolean rotate = true;
    
    /** Number of days to retain log files (-1 for unlimited, default: -1) */
    private int maxDays = -1;
    
    /** Whether to buffer log output for performance (default: true) */
    private boolean buffered = true;
}

Configuration Example:

server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=combined
server.tomcat.accesslog.directory=/var/log/tomcat
server.tomcat.accesslog.max-days=30
server.tomcat.accesslog.buffered=false

Static Resource Configuration

Configuration for static resource handling under server.tomcat.resource.* prefix.

/**
 * Static resource configuration for caching and optimization
 */
public static class Resource {
    
    /** Whether to allow caching of static resources (default: true) */
    private boolean allowCaching = true;
    
    /** Time-to-live for cached static resources */
    private Duration cacheTtl;
}

Configuration Example:

server.tomcat.resource.allow-caching=true
server.tomcat.resource.cache-ttl=24h

MBean Registry Configuration

Configuration for Tomcat's MBean registry under server.tomcat.mbeanregistry.* prefix.

/**
 * MBean registry configuration for JMX management
 */
public static class Mbeanregistry {
    
    /** Whether to enable MBean registry (default: false) */
    private boolean enabled = false;
}

Remote IP Valve Configuration

Configuration for X-Forwarded headers processing under server.tomcat.remoteip.* prefix.

/**
 * Remote IP valve configuration for proxy setups
 */
public static class Remoteip {
    
    /** Regular expression for internal proxy IP addresses */
    private String internalProxies;
    
    /** Header name containing the protocol (HTTP/HTTPS) */
    private String protocolHeader;
    
    /** Value indicating HTTPS protocol (default: "https") */
    private String protocolHeaderHttpsValue = "https";
    
    /** Header name containing the original host (default: "X-Forwarded-Host") */
    private String hostHeader = "X-Forwarded-Host";
    
    /** Header name containing the original port (default: "X-Forwarded-Port") */  
    private String portHeader = "X-Forwarded-Port";
    
    /** Header name containing the remote IP address */
    private String remoteIpHeader;
}

Configuration Example:

server.tomcat.remoteip.protocol-header=X-Forwarded-Proto
server.tomcat.remoteip.protocol-header-https-value=https
server.tomcat.remoteip.remote-ip-header=X-Forwarded-For
server.tomcat.remoteip.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|192\\.168\\.\\d{1,3}\\.\\d{1,3}

Complete Configuration Examples

Basic Web Application

# Basic server configuration
server.port=8080
server.servlet.context-path=/myapp

# Tomcat-specific settings
server.tomcat.basedir=/tmp/tomcat
server.tomcat.uri-encoding=UTF-8
server.tomcat.max-connections=5000
server.tomcat.accept-count=100
server.tomcat.connection-timeout=20s

# Thread pool
server.tomcat.threads.max=150
server.tomcat.threads.min-spare=10

# Access logging
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=common
server.tomcat.accesslog.directory=logs

High-Performance Production Setup

# Performance-oriented configuration
server.tomcat.max-connections=10000
server.tomcat.accept-count=200
server.tomcat.connection-timeout=30s
server.tomcat.keep-alive-timeout=15s
server.tomcat.max-keep-alive-requests=100

# Thread pool for high throughput
server.tomcat.threads.max=300
server.tomcat.threads.min-spare=50

# Request size limits
server.tomcat.max-http-form-post-size=10MB
server.tomcat.max-swallow-size=10MB

# Static resource optimization
server.tomcat.resource.allow-caching=true
server.tomcat.resource.cache-ttl=24h

# Access logging for production
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=combined
server.tomcat.accesslog.directory=/var/log/tomcat
server.tomcat.accesslog.max-days=30
server.tomcat.accesslog.buffered=true

Behind Load Balancer/Proxy

# Proxy configuration
server.tomcat.remoteip.protocol-header=X-Forwarded-Proto
server.tomcat.remoteip.protocol-header-https-value=https
server.tomcat.remoteip.remote-ip-header=X-Forwarded-For
server.tomcat.remoteip.host-header=X-Forwarded-Host
server.tomcat.remoteip.port-header=X-Forwarded-Port
server.tomcat.remoteip.internal-proxies=10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}|192\\.168\\.\\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}

# Disable direct redirect handling (let proxy handle)
server.tomcat.redirect-context-root=false
server.tomcat.use-relative-redirects=true

# Connection settings for proxy environment
server.tomcat.connection-timeout=60s
server.tomcat.keep-alive-timeout=30s

Development Environment

# Development-friendly settings
server.port=8080
server.tomcat.basedir=./tomcat-temp

# Relaxed timeout for debugging
server.tomcat.connection-timeout=300s

# Smaller thread pool for development
server.tomcat.threads.max=50
server.tomcat.threads.min-spare=5

# Enable access logging for debugging
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=combined

# Allow relaxed path characters for development
server.tomcat.relaxed-path-chars=<,>,[,\\,],^,`,{,|,}
server.tomcat.relaxed-query-chars=<,>,[,\\,],^,`,{,|,}

Property Validation and Defaults

Properties are validated at startup and provide sensible defaults:

  • Numeric values: Must be positive integers where applicable
  • Duration values: Support standard formats (30s, 5m, 1h, etc.)
  • DataSize values: Support standard formats (1KB, 2MB, 1GB, etc.)
  • File paths: Automatically created if they don't exist
  • Character sets: Must be valid Java charset names
  • Patterns: Validated as proper regular expressions where applicable

Environment-Specific Configuration

Properties can be overridden per environment using Spring Boot profiles:

application-dev.properties:

server.tomcat.threads.max=50
server.tomcat.accesslog.enabled=true

application-prod.properties:

server.tomcat.threads.max=300
server.tomcat.max-connections=10000
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.max-days=90

Install with Tessl CLI

npx tessl i tessl/maven-org-springframework-boot--spring-boot-starter-tomcat

docs

auto-configuration.md

configuration-properties.md

index.md

server-customization.md

web-server-factories.md

tile.json