From 323cae4c508fed6fa0e1092768eeb7e5af827327 Mon Sep 17 00:00:00 2001 From: "Matt (IPv4) Cowley" Date: Thu, 4 Feb 2021 19:28:50 +0000 Subject: [PATCH] Allow setting of custom sizes for types hash (#219) --- src/nginxconfig/generators/conf/nginx.conf.js | 3 +- .../templates/global_sections/nginx.vue | 62 +++++++++++++++++++ 2 files changed, 64 insertions(+), 1 deletion(-) diff --git a/src/nginxconfig/generators/conf/nginx.conf.js b/src/nginxconfig/generators/conf/nginx.conf.js index cd55566..5a554c4 100644 --- a/src/nginxconfig/generators/conf/nginx.conf.js +++ b/src/nginxconfig/generators/conf/nginx.conf.js @@ -66,7 +66,8 @@ export default (domains, global) => { config.http.push(['server_tokens', 'off']); if (!global.logging.logNotFound.computed) config.http.push(['log_not_found', 'off']); - config.http.push(['types_hash_max_size', 2048]); + config.http.push(['types_hash_max_size', global.nginx.typesHashMaxSize.computed]); + config.http.push(['types_hash_bucket_size', global.nginx.typesHashBucketSize.computed]); config.http.push(['client_max_body_size', `${global.nginx.clientMaxBodySize.computed}M`]); config.http.push(['# MIME', '']); diff --git a/src/nginxconfig/templates/global_sections/nginx.vue b/src/nginxconfig/templates/global_sections/nginx.vue index 0e09832..bae29f6 100644 --- a/src/nginxconfig/templates/global_sections/nginx.vue +++ b/src/nginxconfig/templates/global_sections/nginx.vue @@ -116,6 +116,38 @@ THE SOFTWARE. + +
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+ +
+
+
+
+ +
+
+
+
@@ -150,6 +182,16 @@ THE SOFTWARE. default: 16, enabled: true, }, + typesHashMaxSize: { + default: 2048, + options: Array.from({ length: 8 }, (_, i) => Math.pow(2, i + 6)), + enabled: true, + }, + typesHashBucketSize: { + default: 64, + options: Array.from({ length: 10 }, (_, i) => Math.pow(2, i + 4)), + enabled: true, + }, }; export default { @@ -195,6 +237,26 @@ THE SOFTWARE. }, deep: true, }, + // Check hash max size selection is valid + '$props.data.typesHashMaxSize': { + handler(data) { + // This might cause recursion, but seems not to + if (data.enabled) + if (!data.options.includes(data.computed)) + data.computed = data.default; + }, + deep: true, + }, + // Check hash bucket size selection is valid + '$props.data.typesHashBucketSize': { + handler(data) { + // This might cause recursion, but seems not to + if (data.enabled) + if (!data.options.includes(data.computed)) + data.computed = data.default; + }, + deep: true, + }, }, };