mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-02 03:25:56 +01:00
Add possibility to configure form boundaries in Jetty
The configuration options 'maxFormKeys' and 'maxFormContentSize' from Jetty can now be set using the SCM config.yml file or environment variables. This is required, when instances with lots of repositories are to be migrated from 1.x to 3.x.
This commit is contained in:
@@ -53,25 +53,20 @@ If however you have to install plugins manually (for example because you cannot
|
|||||||
|
|
||||||
# Huge number of repositories
|
# Huge number of repositories
|
||||||
|
|
||||||
If you have more than 100 Repositories to migrate, you may have to adapt some configuration and increase the limit of jetty form keys. You can do this by setting the `maxFormKeys` and `maxFormContentSize` of the webapp in `conf/server-config.xml`. You have to add the keys to the `WebAppContext` with the id `"scm-webapp"` e.g.:
|
If you have more than 100 Repositories to migrate, you may have to adapt some configuration and increase the limit of jetty form keys. You can do this by setting the `maxFormKeys` and `maxFormContentSize` in your `conf/config.yml` file. You have to add the keys at top level of the yaml file:
|
||||||
|
|
||||||
```
|
```
|
||||||
<New id="scm-webapp" class="org.eclipse.jetty.webapp.WebAppContext">
|
# base server config
|
||||||
<Set name="contextPath">/scm</Set>
|
## Address to listen 0.0.0.0 means on every interface
|
||||||
<Set name="war">
|
addressBinding: 0.0.0.0
|
||||||
<SystemProperty name="basedir" default="."/>/var/webapp/scm-webapp.war</Set>
|
port: 8080
|
||||||
<!-- disable directory listings -->
|
contextPath: /scm
|
||||||
<Call name="setInitParameter">
|
|
||||||
<Arg>org.eclipse.jetty.servlet.Default.dirAllowed</Arg>
|
## Additions for the huge number of repositories:
|
||||||
<Arg>false</Arg>
|
maxFormContentSize: 1000000
|
||||||
</Call>
|
maxFormKeys: 5000
|
||||||
<Set name="tempDirectory">
|
|
||||||
<SystemProperty name="basedir" default="."/>/work/scm
|
...
|
||||||
</Set>
|
|
||||||
<!-- Set max form keys -->
|
|
||||||
<Set name="maxFormContentSize">1000000</Set>
|
|
||||||
<Set name="maxFormKeys">5000</Set>
|
|
||||||
</New>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
The value for `maxFormKeys` should be the count of your repositories * 3 + 10. The `maxFormContentSize` depends on the length of your repository namespace and name, but you should be safe with repository count * 100.
|
The value for `maxFormKeys` should be the count of your repositories * 3 + 10. The `maxFormContentSize` depends on the length of your repository namespace and name, but you should be safe with repository count * 100.
|
||||||
|
|||||||
2
gradle/changelog/form_config.yaml
Normal file
2
gradle/changelog/form_config.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
- type: fixed
|
||||||
|
description: Possibility to configure 'maxFormKeys' and 'maxFormContentSize' in Jetty
|
||||||
@@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package sonia.scm.server;
|
package sonia.scm.server;
|
||||||
|
|
||||||
|
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||||
|
|
||||||
public class ServerConfigYaml {
|
public class ServerConfigYaml {
|
||||||
|
|
||||||
private static final String SCM_SERVER_PREFIX = "SCM_";
|
private static final String SCM_SERVER_PREFIX = "SCM_";
|
||||||
@@ -30,6 +32,8 @@ public class ServerConfigYaml {
|
|||||||
// Resolves the client ip instead of the reverse proxy ip if the X-Forwarded-For header is present
|
// Resolves the client ip instead of the reverse proxy ip if the X-Forwarded-For header is present
|
||||||
private boolean forwardHeadersEnabled = false;
|
private boolean forwardHeadersEnabled = false;
|
||||||
private int idleTimeout = 0;
|
private int idleTimeout = 0;
|
||||||
|
private int maxFormContentSize = ContextHandler.DEFAULT_MAX_FORM_CONTENT_SIZE;
|
||||||
|
private int maxFormKeys = ContextHandler.DEFAULT_MAX_FORM_KEYS;
|
||||||
|
|
||||||
// ### SSL-related config
|
// ### SSL-related config
|
||||||
// Only configure SSL if the key store path is set
|
// Only configure SSL if the key store path is set
|
||||||
@@ -150,6 +154,22 @@ public class ServerConfigYaml {
|
|||||||
this.idleTimeout = idleTimeout;
|
this.idleTimeout = idleTimeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getMaxFormContentSize() {
|
||||||
|
return getEnvWithDefault("MAX_FORM_CONTENT_SIZE", maxFormContentSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxFormContentSize(int maxFormContentSize) {
|
||||||
|
this.maxFormContentSize = maxFormContentSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxFormKeys() {
|
||||||
|
return getEnvWithDefault("MAX_FORM_KEYS", maxFormKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMaxFormKeys(int maxFormKeys) {
|
||||||
|
this.maxFormKeys = maxFormKeys;
|
||||||
|
}
|
||||||
|
|
||||||
static int getEnvWithDefault(String envKey, int configValue) {
|
static int getEnvWithDefault(String envKey, int configValue) {
|
||||||
String value = getEnv(envKey);
|
String value = getEnv(envKey);
|
||||||
return value != null ? Integer.parseInt(value) : configValue;
|
return value != null ? Integer.parseInt(value) : configValue;
|
||||||
|
|||||||
@@ -152,6 +152,10 @@ public final class ServerConfiguration {
|
|||||||
);
|
);
|
||||||
System.out.printf("Set webapp temp directory to %s%n", webappTempDir);
|
System.out.printf("Set webapp temp directory to %s%n", webappTempDir);
|
||||||
webApp.setTempDirectory(webappTempDir);
|
webApp.setTempDirectory(webappTempDir);
|
||||||
|
webApp.setMaxFormContentSize(configYaml.getMaxFormContentSize());
|
||||||
|
System.out.println("Set webapp max form content size to " + configYaml.getMaxFormContentSize());
|
||||||
|
webApp.setMaxFormKeys(configYaml.getMaxFormKeys());
|
||||||
|
System.out.println("Set webapp max form keys to " + configYaml.getMaxFormKeys());
|
||||||
return webApp;
|
return webApp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,8 +209,7 @@ public final class ServerConfiguration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Connector connector : server.getConnectors()) {
|
for (Connector connector : server.getConnectors()) {
|
||||||
if (connector instanceof ServerConnector) {
|
if (connector instanceof ServerConnector serverConnector) {
|
||||||
ServerConnector serverConnector = (ServerConnector) connector;
|
|
||||||
String scheme = "http";
|
String scheme = "http";
|
||||||
String protocol = serverConnector.getDefaultProtocol();
|
String protocol = serverConnector.getDefaultProtocol();
|
||||||
if ("SSL".equalsIgnoreCase(protocol) || "TLS".equalsIgnoreCase(protocol)) {
|
if ("SSL".equalsIgnoreCase(protocol) || "TLS".equalsIgnoreCase(protocol)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user