NIFI-4603 - Externalize Max HTTP Header Size to nifi.properties

Signed-off-by: Pierre Villard <pierre.villard.fr@gmail.com>

This closes #2271.
This commit is contained in:
Matthew Burgess 2017-11-13 21:12:11 -05:00 committed by Pierre Villard
parent 7f8007f22a
commit 53de8c93ba
5 changed files with 13 additions and 3 deletions

View File

@ -176,6 +176,7 @@ public abstract class NiFiProperties {
public static final String WEB_HTTPS_NETWORK_INTERFACE_PREFIX = "nifi.web.https.network.interface."; public static final String WEB_HTTPS_NETWORK_INTERFACE_PREFIX = "nifi.web.https.network.interface.";
public static final String WEB_WORKING_DIR = "nifi.web.jetty.working.directory"; public static final String WEB_WORKING_DIR = "nifi.web.jetty.working.directory";
public static final String WEB_THREADS = "nifi.web.jetty.threads"; public static final String WEB_THREADS = "nifi.web.jetty.threads";
public static final String WEB_MAX_HEADER_SIZE = "nifi.web.max.header.size";
// ui properties // ui properties
public static final String UI_BANNER_TEXT = "nifi.ui.banner.text"; public static final String UI_BANNER_TEXT = "nifi.ui.banner.text";
@ -232,6 +233,7 @@ public abstract class NiFiProperties {
public static final Integer DEFAULT_REMOTE_INPUT_PORT = null; public static final Integer DEFAULT_REMOTE_INPUT_PORT = null;
public static final Path DEFAULT_TEMPLATE_DIRECTORY = Paths.get("conf", "templates"); public static final Path DEFAULT_TEMPLATE_DIRECTORY = Paths.get("conf", "templates");
public static final int DEFAULT_WEB_THREADS = 200; public static final int DEFAULT_WEB_THREADS = 200;
public static final String DEFAULT_WEB_MAX_HEADER_SIZE = "16 KB";
public static final String DEFAULT_WEB_WORKING_DIR = "./work/jetty"; public static final String DEFAULT_WEB_WORKING_DIR = "./work/jetty";
public static final String DEFAULT_NAR_WORKING_DIR = "./work/nar"; public static final String DEFAULT_NAR_WORKING_DIR = "./work/nar";
public static final String DEFAULT_COMPONENT_DOCS_DIRECTORY = "./work/docs/components"; public static final String DEFAULT_COMPONENT_DOCS_DIRECTORY = "./work/docs/components";
@ -584,6 +586,10 @@ public abstract class NiFiProperties {
return sslPort; return sslPort;
} }
public String getWebMaxHeaderSize() {
return getProperty(WEB_MAX_HEADER_SIZE, DEFAULT_WEB_MAX_HEADER_SIZE);
}
public int getWebThreads() { public int getWebThreads() {
return getIntegerProperty(WEB_THREADS, DEFAULT_WEB_THREADS); return getIntegerProperty(WEB_THREADS, DEFAULT_WEB_THREADS);
} }

View File

@ -3004,6 +3004,7 @@ nifi.web.https.network.interface.eth1=eth1 +
Providing three total network interfaces, including `nifi.web.https.network.interface.default`. Providing three total network interfaces, including `nifi.web.https.network.interface.default`.
|nifi.web.jetty.working.directory|The location of the Jetty working directory. The default value is `./work/jetty`. |nifi.web.jetty.working.directory|The location of the Jetty working directory. The default value is `./work/jetty`.
|nifi.web.jetty.threads|The number of Jetty threads. The default value is `200`. |nifi.web.jetty.threads|The number of Jetty threads. The default value is `200`.
|nifi.web.max.header.size|The maximum size allowed for request and response headers. The default value is 16 KB.
|==== |====
=== Security Properties === Security Properties

View File

@ -131,6 +131,7 @@
<nifi.web.https.network.interface.default /> <nifi.web.https.network.interface.default />
<nifi.jetty.work.dir>./work/jetty</nifi.jetty.work.dir> <nifi.jetty.work.dir>./work/jetty</nifi.jetty.work.dir>
<nifi.web.jetty.threads>200</nifi.web.jetty.threads> <nifi.web.jetty.threads>200</nifi.web.jetty.threads>
<nifi.web.max.header.size>16 KB</nifi.web.max.header.size>
<!-- nifi.properties: security properties --> <!-- nifi.properties: security properties -->
<nifi.security.keystore /> <nifi.security.keystore />

View File

@ -136,6 +136,7 @@ nifi.web.https.port=${nifi.web.https.port}
nifi.web.https.network.interface.default=${nifi.web.https.network.interface.default} nifi.web.https.network.interface.default=${nifi.web.https.network.interface.default}
nifi.web.jetty.working.directory=${nifi.jetty.work.dir} nifi.web.jetty.working.directory=${nifi.jetty.work.dir}
nifi.web.jetty.threads=${nifi.web.jetty.threads} nifi.web.jetty.threads=${nifi.web.jetty.threads}
nifi.web.max.header.size=${nifi.web.max.header.size}
# security properties # # security properties #
nifi.sensitive.props.key= nifi.sensitive.props.key=

View File

@ -30,6 +30,7 @@ import org.apache.nifi.documentation.DocGenerator;
import org.apache.nifi.lifecycle.LifeCycleStartException; import org.apache.nifi.lifecycle.LifeCycleStartException;
import org.apache.nifi.nar.ExtensionManager; import org.apache.nifi.nar.ExtensionManager;
import org.apache.nifi.nar.ExtensionMapping; import org.apache.nifi.nar.ExtensionMapping;
import org.apache.nifi.processor.DataUnit;
import org.apache.nifi.security.util.KeyStoreUtils; import org.apache.nifi.security.util.KeyStoreUtils;
import org.apache.nifi.services.FlowService; import org.apache.nifi.services.FlowService;
import org.apache.nifi.ui.extension.UiExtension; import org.apache.nifi.ui.extension.UiExtension;
@ -109,7 +110,6 @@ public class JettyServer implements NiFiServer {
private static final Logger logger = LoggerFactory.getLogger(JettyServer.class); private static final Logger logger = LoggerFactory.getLogger(JettyServer.class);
private static final String WEB_DEFAULTS_XML = "org/apache/nifi/web/webdefault.xml"; private static final String WEB_DEFAULTS_XML = "org/apache/nifi/web/webdefault.xml";
private static final int HEADER_BUFFER_SIZE = 16 * 1024; // 16kb
private static final FileFilter WAR_FILTER = new FileFilter() { private static final FileFilter WAR_FILTER = new FileFilter() {
@Override @Override
@ -578,8 +578,9 @@ public class JettyServer implements NiFiServer {
private void configureConnectors(final Server server) throws ServerConfigurationException { private void configureConnectors(final Server server) throws ServerConfigurationException {
// create the http configuration // create the http configuration
final HttpConfiguration httpConfiguration = new HttpConfiguration(); final HttpConfiguration httpConfiguration = new HttpConfiguration();
httpConfiguration.setRequestHeaderSize(HEADER_BUFFER_SIZE); final int headerSize = DataUnit.parseDataSize(props.getWebMaxHeaderSize(), DataUnit.B).intValue();
httpConfiguration.setResponseHeaderSize(HEADER_BUFFER_SIZE); httpConfiguration.setRequestHeaderSize(headerSize);
httpConfiguration.setResponseHeaderSize(headerSize);
if (props.getPort() != null) { if (props.getPort() != null) {
final Integer port = props.getPort(); final Integer port = props.getPort();