diff --git a/src/nginxconfig/generators/conf/website.conf.js b/src/nginxconfig/generators/conf/website.conf.js index e6f99bf..16c9e00 100644 --- a/src/nginxconfig/generators/conf/website.conf.js +++ b/src/nginxconfig/generators/conf/website.conf.js @@ -26,6 +26,7 @@ THE SOFTWARE. import { getSslCertificate, getSslCertificateKey } from '../../util/get_ssl_certificate'; import { extensions, gzipTypes } from '../../util/types_extensions'; +import { getDomainAccessLog, getDomainErrorLog } from '../../util/logging'; import commonHsts from '../../util/common_hsts'; import securityConf from './security.conf'; import pythonConf from './python_uwsgi.conf'; @@ -224,17 +225,10 @@ export default (domain, domains, global, ipPortPairs) => { serverConfig.push(['# logging', '']); if (domain.logging.accessLog.computed) - serverConfig.push(['access_log', - domain.logging.accessLogPath.computed.trim() + - (global.logging.cloudflare.computed ? ' cloudflare' : '') + - (domain.logging.accessLogParameters.computed ? ` ${domain.logging.accessLogParameters.computed.trim()}`: ''), - ]); + serverConfig.push(['access_log', getDomainAccessLog(domain, global)]); if (domain.logging.errorLog.computed) - serverConfig.push(['error_log', - domain.logging.errorLogPath.computed.trim() + - ` ${domain.logging.errorLogLevel.computed}`, - ]); + serverConfig.push(['error_log', getDomainErrorLog(domain)]); } // index.php diff --git a/src/nginxconfig/templates/domain_sections/logging.vue b/src/nginxconfig/templates/domain_sections/logging.vue index ba1eba4..faf411c 100644 --- a/src/nginxconfig/templates/domain_sections/logging.vue +++ b/src/nginxconfig/templates/domain_sections/logging.vue @@ -44,7 +44,7 @@ THE SOFTWARE. v-model="accessLogPath" class="input" type="text" - :placeholder="$props.data.accessLogPath.computed" + :placeholder="`/var/log/nginx/${$parent.$props.data.server.domain.computed}.access.log`" /> @@ -86,7 +86,7 @@ THE SOFTWARE. v-model="errorLogPath" class="input" type="text" - :placeholder="$props.data.errorLogPath.computed" + :placeholder="`/var/log/nginx/${$parent.$props.data.server.domain.computed}.error.log`" /> @@ -130,7 +130,6 @@ THE SOFTWARE. }, accessLogPath: { default: '', - computed: '/var/log/nginx/example.com.access.log', // No default value, but a default computed enabled: true, }, accessLogParameters: { @@ -143,7 +142,6 @@ THE SOFTWARE. }, errorLogPath: { default: '', - computed: '/var/log/nginx/example.com.error.log', // No default value, but a default computed enabled: true, }, errorLogLevel: { diff --git a/src/nginxconfig/util/logging.js b/src/nginxconfig/util/logging.js index de5f0de..d0f048f 100644 --- a/src/nginxconfig/util/logging.js +++ b/src/nginxconfig/util/logging.js @@ -24,6 +24,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +export const getDomainAccessLog = (domain, global) => { + let path = domain.logging.accessLogPath.computed.trim(); + if (!path) { + path = `/var/log/nginx/${domain.server.domain.computed}.access.log`; + } + + return path + + (global.logging.cloudflare.computed ? ' cloudflare' : '') + + (domain.logging.accessLogParameters.computed.trim() ? ` ${domain.logging.accessLogParameters.computed.trim()}`: '') +}; + +export const getDomainErrorLog = (domain) => { + let path = domain.logging.errorLogPath.computed.trim() + if (!path) { + path = `/var/log/nginx/${domain.server.domain.computed}.error.log`; + } + return `${path} ${domain.logging.errorLogLevel.computed}`; +} + export const accessLogParamsDefault = 'buffer=512k flush=1m'; export const errorLogLevelDefault = 'warn';