|
15 | 15 |
|
16 | 16 | import java.io.File; |
17 | 17 | import java.util.ArrayList; |
| 18 | +import java.util.HashMap; |
18 | 19 | import java.util.List; |
19 | 20 | import java.util.Map; |
20 | 21 |
|
@@ -66,36 +67,43 @@ public static void main(String[] args) |
66 | 67 |
|
67 | 68 | SpringApplication application = new SpringApplication(LabKeyServer.class); |
68 | 69 | application.addListeners(new ApplicationPidFileWriter("./labkey.pid")); |
69 | | - application.setDefaultProperties(Map.of( |
70 | | - "server.tomcat.basedir", ".", |
71 | | - "server.tomcat.accesslog.directory", logHome, |
72 | | - |
73 | | - // Enable HTTP compression for response content |
74 | | - "server.compression.enabled", "true", |
75 | | - |
76 | | - "server.tomcat.accesslog.enabled", "true", |
77 | | - "server.tomcat.accesslog.pattern", "%h %l %u %t \"%r\" %s %b %D %S %I \"%{Referer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i", |
78 | | - "jsonaccesslog.pattern", "%h %t %m %U %s %b %D %S \"%{Referer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i", |
79 | | - |
80 | | - // Issue 52415: Omit stack traces from Tomcat error pages by default, but propagate error messages |
81 | | - "server.error.include-stacktrace", "never", |
82 | | - "server.error.include-message", "always", |
83 | | - |
84 | | - // A strong report-only Content Security Policy that reports violations to this server |
85 | | - "csp.report", """ |
86 | | - default-src 'self' ; |
87 | | - connect-src 'self' ${CONNECTION.SOURCES} ; |
88 | | - object-src 'none' ; |
89 | | - style-src 'self' 'unsafe-inline' ${STYLE.SOURCES} ; |
90 | | - img-src 'self' data: ${IMAGE.SOURCES} ; |
91 | | - font-src 'self' data: ${FONT.SOURCES} ; |
92 | | - script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}' ; |
93 | | - base-uri 'self' ; |
94 | | - frame-ancestors 'self' ; |
95 | | - frame-src 'self' ${FRAME.SOURCES} ; |
96 | | - report-uri ${context.contextPath:}/admin-contentSecurityPolicyReport.api?cspVersion=r11&${CSP.REPORT.PARAMS} |
97 | | - """ |
98 | | - )); |
| 70 | + application.setDefaultProperties(new HashMap<>() |
| 71 | + {{ |
| 72 | + put("server.tomcat.basedir", "."); |
| 73 | + put("server.tomcat.accesslog.directory", logHome); |
| 74 | + |
| 75 | + // Boost limits imposed by Tomcat v10.1.42 |
| 76 | + put("server.tomcat.max-part-count", 500); |
| 77 | + put("server.tomcat.max-part-header-size", 512); |
| 78 | + put("server.tomcat.max-connections", 250); |
| 79 | + |
| 80 | + // Enable HTTP compression for response content |
| 81 | + put("server.compression.enabled", "true"); |
| 82 | + |
| 83 | + put("server.tomcat.accesslog.enabled", "true"); |
| 84 | + put("server.tomcat.accesslog.pattern", "%h %l %u %t \"%r\" %s %b %D %S %I \"%{Referer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i"); |
| 85 | + put("jsonaccesslog.pattern", "%h %t %m %U %s %b %D %S \"%{Referer}i\" \"%{User-Agent}i\" %{LABKEY.username}s %{X-Forwarded-For}i"); |
| 86 | + |
| 87 | + // Issue 52415: Omit stack traces from Tomcat error pages by default, but propagate error messages |
| 88 | + put("server.error.include-stacktrace", "never"); |
| 89 | + put("server.error.include-message", "always"); |
| 90 | + |
| 91 | + // A strong report-only Content Security Policy that reports violations to this server |
| 92 | + put("csp.report", """ |
| 93 | + default-src 'self' ; |
| 94 | + connect-src 'self' ${CONNECTION.SOURCES} ; |
| 95 | + object-src 'none' ; |
| 96 | + style-src 'self' 'unsafe-inline' ${STYLE.SOURCES} ; |
| 97 | + img-src 'self' data: ${IMAGE.SOURCES} ; |
| 98 | + font-src 'self' data: ${FONT.SOURCES} ; |
| 99 | + script-src 'unsafe-eval' 'strict-dynamic' 'nonce-${REQUEST.SCRIPT.NONCE}' ; |
| 100 | + base-uri 'self' ; |
| 101 | + frame-ancestors 'self' ; |
| 102 | + frame-src 'self' ${FRAME.SOURCES} ; |
| 103 | + report-uri ${context.contextPath:}/admin-contentSecurityPolicyReport.api?cspVersion=r11&${CSP.REPORT.PARAMS} |
| 104 | + """); |
| 105 | + }} |
| 106 | + ); |
99 | 107 | application.setBannerMode(Banner.Mode.OFF); |
100 | 108 | application.run(args); |
101 | 109 | } |
|
0 commit comments