From 2819b0db93a9caf26ef8e4f93f3e09ceb34406f6 Mon Sep 17 00:00:00 2001 From: Kobi Meirson Date: Tue, 1 Nov 2022 12:59:11 +0200 Subject: [PATCH] feat: option to turn on access_log and error_log on redirects --- .../generators/conf/website.conf.js | 18 +++++++- .../en/templates/domain_sections/logging.js | 1 + .../templates/domain_sections/logging.vue | 42 +++++++++++++++++++ 3 files changed, 60 insertions(+), 1 deletion(-) diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index 607e564..5dbe7d4 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -127,6 +127,14 @@ const httpRedirectConfig = (domain, global, ipPortPairs, domainName, redirectDom config.push(...httpListen(domain, global, ipPortPairs)); config.push(['server_name', domainName]); + // Logging + if (domain.logging.redirectAccessLog.computed) { + config.push(['access_log', getDomainAccessLog(domain, global)]); + } + if (domain.logging.redirectErrorLog.computed) { + config.push(['error_log', getDomainErrorLog(domain)]); + } + if (domain.https.certType.computed === 'letsEncrypt') { // Let's encrypt @@ -410,7 +418,15 @@ export default (domain, domains, global, ipPortPairs) => { // HTTPS redirectConfig.push(...sslConfig(domain, global)); - + + // Logging + if (domain.logging.redirectAccessLog.computed) { + redirectConfig.push(['access_log', getDomainAccessLog(domain, global)]); + } + if (domain.logging.redirectErrorLog.computed) { + redirectConfig.push(['error_log', getDomainErrorLog(domain)]); + } + redirectConfig.push(['return', `301 http${domain.https.https.computed ? 's' : ''}://${domain.server.wwwSubdomain.computed ? 'www.' : ''}${domain.server.domain.computed}$request_uri`]); diff --git a/src/nginxconfig/i18n/en/templates/domain_sections/logging.js b/src/nginxconfig/i18n/en/templates/domain_sections/logging.js index 6198558..342d4b9 100644 --- a/src/nginxconfig/i18n/en/templates/domain_sections/logging.js +++ b/src/nginxconfig/i18n/en/templates/domain_sections/logging.js @@ -31,4 +31,5 @@ export default { enableForThisDomain: `${common.enable} for this domain`, arguments: 'arguments', level: 'logging level', + forRedirects: 'for redirects', }; diff --git a/src/nginxconfig/templates/domain_sections/logging.vue b/src/nginxconfig/templates/domain_sections/logging.vue index 272cb7b..1deecb5 100644 --- a/src/nginxconfig/templates/domain_sections/logging.vue +++ b/src/nginxconfig/templates/domain_sections/logging.vue @@ -69,6 +69,23 @@ THE SOFTWARE. +
+
+ +
+
+
+
+
+ + {{ $t('common.enable') }} + +
+
+
+
+
+
@@ -113,6 +130,23 @@ THE SOFTWARE.
+ +
+
+ +
+
+
+
+
+ + {{ $t('common.enable') }} + +
+
+
+
+
@@ -136,6 +170,10 @@ THE SOFTWARE. default: accessLogParamsDefault, enabled: true, }, + redirectAccessLog: { + default: false, + enabled: true, + }, errorLogEnabled: { default: true, enabled: true, @@ -149,6 +187,10 @@ THE SOFTWARE. options: errorLogLevelOptions, enabled: true, }, + redirectErrorLog: { + default: false, + enabled: true, + }, }; export default {