feat: option to turn on access_log and error_log on redirects

pull/399/head
Kobi Meirson 2022-11-01 12:59:11 +02:00
parent e02f20d993
commit 2819b0db93
No known key found for this signature in database
GPG Key ID: 5D66F732B037CDE1
3 changed files with 60 additions and 1 deletions

View File

@ -127,6 +127,14 @@ const httpRedirectConfig = (domain, global, ipPortPairs, domainName, redirectDom
config.push(...httpListen(domain, global, ipPortPairs)); config.push(...httpListen(domain, global, ipPortPairs));
config.push(['server_name', domainName]); 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') { if (domain.https.certType.computed === 'letsEncrypt') {
// Let's encrypt // Let's encrypt
@ -411,6 +419,14 @@ export default (domain, domains, global, ipPortPairs) => {
// HTTPS // HTTPS
redirectConfig.push(...sslConfig(domain, global)); 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', redirectConfig.push(['return',
`301 http${domain.https.https.computed ? 's' : ''}://${domain.server.wwwSubdomain.computed ? 'www.' : ''}${domain.server.domain.computed}$request_uri`]); `301 http${domain.https.https.computed ? 's' : ''}://${domain.server.wwwSubdomain.computed ? 'www.' : ''}${domain.server.domain.computed}$request_uri`]);

View File

@ -31,4 +31,5 @@ export default {
enableForThisDomain: `${common.enable} for this domain`, enableForThisDomain: `${common.enable} for this domain`,
arguments: 'arguments', arguments: 'arguments',
level: 'logging level', level: 'logging level',
forRedirects: 'for redirects',
}; };

View File

@ -69,6 +69,23 @@ THE SOFTWARE.
</div> </div>
</div> </div>
<div class="field is-horizontal is-aligned-top">
<div class="field-label has-small-margin-top">
<label class="label">access_log {{ $t('templates.domainSections.logging.forRedirects') }}</label>
</div>
<div class="field-body">
<div class="field">
<div :class="`control${redirectAccessLogChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="redirectAccessLog" class="p-default p-curve p-fill p-icon">
{{ $t('common.enable') }}
</PrettyCheck>
</div>
</div>
</div>
</div>
</div>
<div class="field is-horizontal is-aligned-top"> <div class="field is-horizontal is-aligned-top">
<div class="field-label has-small-margin-top"> <div class="field-label has-small-margin-top">
<label class="label">error_log {{ $t('templates.domainSections.logging.byDomain') }}</label> <label class="label">error_log {{ $t('templates.domainSections.logging.byDomain') }}</label>
@ -113,6 +130,23 @@ THE SOFTWARE.
</div> </div>
</div> </div>
</div> </div>
<div class="field is-horizontal is-aligned-top">
<div class="field-label has-small-margin-top">
<label class="label">error_log {{ $t('templates.domainSections.logging.forRedirects') }}</label>
</div>
<div class="field-body">
<div class="field">
<div :class="`control${redirectErrorLogChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="redirectErrorLog" class="p-default p-curve p-fill p-icon">
{{ $t('common.enable') }}
</PrettyCheck>
</div>
</div>
</div>
</div>
</div>
</div> </div>
</template> </template>
@ -136,6 +170,10 @@ THE SOFTWARE.
default: accessLogParamsDefault, default: accessLogParamsDefault,
enabled: true, enabled: true,
}, },
redirectAccessLog: {
default: false,
enabled: true,
},
errorLogEnabled: { errorLogEnabled: {
default: true, default: true,
enabled: true, enabled: true,
@ -149,6 +187,10 @@ THE SOFTWARE.
options: errorLogLevelOptions, options: errorLogLevelOptions,
enabled: true, enabled: true,
}, },
redirectErrorLog: {
default: false,
enabled: true,
},
}; };
export default { export default {