Skip to content

Commit 7710b9b

Browse files
authored
Upgrade Spring Boot and set reasonable request limits (#1104)
1 parent 032176f commit 7710b9b

File tree

5 files changed

+16
-44
lines changed

5 files changed

+16
-44
lines changed

gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ windowsProteomicsBinariesVersion=1.0
6060
artifactoryPluginVersion=5.2.5
6161
gradleNodePluginVersion=7.1.0
6262
gradlePluginsVersion=6.1.0
63-
owaspDependencyCheckPluginVersion=12.1.0
63+
owaspDependencyCheckPluginVersion=12.1.3
6464
versioningPluginVersion=1.1.2
6565

6666
# Versions of node and npm to use during the build. If set, these versions
@@ -290,7 +290,7 @@ slf4jLog4jApiVersion=2.0.16
290290
snappyJavaVersion=1.1.10.7
291291

292292
# Also, update apacheTomcatVersion above to match Spring Boot's Tomcat dependency version
293-
springBootVersion=3.4.5
293+
springBootVersion=3.5.3
294294
# This usually matches the Spring Framework version dictated by springBootVersion
295295
springVersion=6.2.8
296296

server/configs/application.properties

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,13 @@ context.encryptionKey=@@encryptionKey@@
6666
#context.bypass2FA=true
6767
#context.workDirLocation=/path/to/desired/workDir
6868

69-
## Tomcat v10.1.42 lowered the default for part count from 1000 to 10. Our default is now 500, but can be overridden here.
70-
## Header size default changed from 10Kb to 512, which is also our default.
71-
#context.maxConnectorPartCount=500
72-
#context.maxConnectorPartHeaderSize=512
69+
## Tomcat v10.1.42 lowered the default for part count from 1000 to 10. Our default is now 500.
70+
## Tomcat also lowered the header size default from 10Kb to 512, which is also our default.
71+
## We lower max connections from default 8192 to 250, providing ample concurrent requests for LabKey Server scenarios.
72+
## These settings can be overridden if needed, but reasonable limits reduce your server's vulnerability to DoS attacks.
73+
server.tomcat.max-part-count=500
74+
server.tomcat.max-part-header-size=512
75+
server.tomcat.max-connections=250
7376

7477
## SMTP configuration
7578
mail.smtpHost=@@smtpHost@@

server/configs/webapps/embedded/config/application.properties

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,13 @@ mail.smtpUser=Anonymous
103103
#context.bypass2FA=true
104104
#context.workDirLocation=@@/path/to/desired/workDir@@
105105

106-
## Tomcat v10.1.42 lowered the default for part count from 1000 to 10. Our default is now 500, but can be overridden here.
107-
## Header size default changed from 10Kb to 512, which is also our default.
108-
#context.maxConnectorPartCount=500
109-
#context.maxConnectorPartHeaderSize=512
106+
## Tomcat v10.1.42 lowered the default for part count from 1000 to 10. Our default is now 500.
107+
## Tomcat also lowered the header size default from 10Kb to 512, which is also our default.
108+
## We lower max connections from default 8192 to 250, providing ample concurrent requests for LabKey Server scenarios.
109+
## These settings can be overridden if needed, but reasonable limits reduce your server's vulnerability to DoS attacks.
110+
server.tomcat.max-part-count=500
111+
server.tomcat.max-part-header-size=512
112+
server.tomcat.max-connections=250
110113

111114
## Other webapps to be deployed, most commonly to deliver a set of static files. The context path to deploy into is the
112115
## property name after the "context.additionalWebapps." prefix, and the value is the location of the webapp on disk

server/embedded/src/org/labkey/embedded/LabKeyServer.java

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import org.springframework.boot.autoconfigure.SpringBootApplication;
88
import org.springframework.boot.context.ApplicationPidFileWriter;
99
import org.springframework.boot.context.properties.ConfigurationProperties;
10-
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
1110
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
1211
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
1312
import org.springframework.context.annotation.Bean;
@@ -138,14 +137,6 @@ public WebServerFactoryCustomizer<TomcatServletWebServerFactory> customizer()
138137
return customizer -> customizer.setDisableMBeanRegistry(false);
139138
}
140139

141-
@Bean
142-
TomcatConnectorCustomizer connectorCustomizer() {
143-
return (connector) -> {
144-
connector.setMaxPartCount(contextSource().getMaxConnectorPartCount());
145-
connector.setMaxPartHeaderSize(contextSource().getMaxConnectorPartHeaderSize());
146-
};
147-
}
148-
149140
@Bean
150141
public TomcatServletWebServerFactory servletContainerFactory()
151142
{
@@ -158,7 +149,6 @@ public TomcatServletWebServerFactory servletContainerFactory()
158149
Connector httpConnector = new Connector();
159150
httpConnector.setScheme("http");
160151
httpConnector.setPort(contextProperties.getHttpPort());
161-
result.getTomcatConnectorCustomizers().forEach(customizer -> customizer.customize(httpConnector));
162152
result.addAdditionalTomcatConnectors(httpConnector);
163153
}
164154

@@ -456,9 +446,6 @@ public static class ContextProperties
456446
private Map<String, Map<String, Map<String, String>>> resources;
457447
private Map<String, String> additionalWebapps;
458448

459-
private Integer maxConnectorPartCount = 500;
460-
private Integer maxConnectorPartHeaderSize = 512;
461-
462449
public List<String> getDataSourceName()
463450
{
464451
return dataSourceName;
@@ -721,26 +708,6 @@ public void setAdditionalWebapps(Map<String, String> additionalWebapps)
721708
{
722709
this.additionalWebapps = additionalWebapps;
723710
}
724-
725-
public Integer getMaxConnectorPartCount()
726-
{
727-
return maxConnectorPartCount;
728-
}
729-
730-
public void setMaxConnectorPartCount(Integer maxConnectorPartCount)
731-
{
732-
this.maxConnectorPartCount = maxConnectorPartCount;
733-
}
734-
735-
public Integer getMaxConnectorPartHeaderSize()
736-
{
737-
return maxConnectorPartHeaderSize;
738-
}
739-
740-
public void setMaxConnectorPartHeaderSize(Integer maxConnectorPartHeaderSize)
741-
{
742-
this.maxConnectorPartHeaderSize = maxConnectorPartHeaderSize;
743-
}
744711
}
745712

746713
@Configuration

server/embedded/src/org/labkey/embedded/LabKeyTomcatServletWebServerFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public LabKeyTomcatServletWebServerFactory(LabKeyServer server)
3838

3939
addConnectorCustomizers(connector -> {
4040
LabKeyServer.TomcatProperties props = _server.tomcatProperties();
41-
_server.connectorCustomizer().customize(connector);
4241

4342
if (props.getUseBodyEncodingForURI() != null)
4443
{

0 commit comments

Comments
 (0)