fix(cr): don't use default computed values

pull/399/head
Kobi Meirson 2022-10-20 15:45:58 +03:00
parent c73414b4a9
commit e7a6b2a535
No known key found for this signature in database
GPG Key ID: 5D66F732B037CDE1
3 changed files with 24 additions and 13 deletions

View File

@ -26,6 +26,7 @@ THE SOFTWARE.
import { getSslCertificate, getSslCertificateKey } from '../../util/get_ssl_certificate'; import { getSslCertificate, getSslCertificateKey } from '../../util/get_ssl_certificate';
import { extensions, gzipTypes } from '../../util/types_extensions'; import { extensions, gzipTypes } from '../../util/types_extensions';
import { getDomainAccessLog, getDomainErrorLog } from '../../util/logging';
import commonHsts from '../../util/common_hsts'; import commonHsts from '../../util/common_hsts';
import securityConf from './security.conf'; import securityConf from './security.conf';
import pythonConf from './python_uwsgi.conf'; import pythonConf from './python_uwsgi.conf';
@ -224,17 +225,10 @@ export default (domain, domains, global, ipPortPairs) => {
serverConfig.push(['# logging', '']); serverConfig.push(['# logging', '']);
if (domain.logging.accessLog.computed) if (domain.logging.accessLog.computed)
serverConfig.push(['access_log', serverConfig.push(['access_log', getDomainAccessLog(domain, global)]);
domain.logging.accessLogPath.computed.trim() +
(global.logging.cloudflare.computed ? ' cloudflare' : '') +
(domain.logging.accessLogParameters.computed ? ` ${domain.logging.accessLogParameters.computed.trim()}`: ''),
]);
if (domain.logging.errorLog.computed) if (domain.logging.errorLog.computed)
serverConfig.push(['error_log', serverConfig.push(['error_log', getDomainErrorLog(domain)]);
domain.logging.errorLogPath.computed.trim() +
` ${domain.logging.errorLogLevel.computed}`,
]);
} }
// index.php // index.php

View File

@ -44,7 +44,7 @@ THE SOFTWARE.
v-model="accessLogPath" v-model="accessLogPath"
class="input" class="input"
type="text" type="text"
:placeholder="$props.data.accessLogPath.computed" :placeholder="`/var/log/nginx/${$parent.$props.data.server.domain.computed}.access.log`"
/> />
</div> </div>
</div> </div>
@ -86,7 +86,7 @@ THE SOFTWARE.
v-model="errorLogPath" v-model="errorLogPath"
class="input" class="input"
type="text" type="text"
:placeholder="$props.data.errorLogPath.computed" :placeholder="`/var/log/nginx/${$parent.$props.data.server.domain.computed}.error.log`"
/> />
</div> </div>
</div> </div>
@ -130,7 +130,6 @@ THE SOFTWARE.
}, },
accessLogPath: { accessLogPath: {
default: '', default: '',
computed: '/var/log/nginx/example.com.access.log', // No default value, but a default computed
enabled: true, enabled: true,
}, },
accessLogParameters: { accessLogParameters: {
@ -143,7 +142,6 @@ THE SOFTWARE.
}, },
errorLogPath: { errorLogPath: {
default: '', default: '',
computed: '/var/log/nginx/example.com.error.log', // No default value, but a default computed
enabled: true, enabled: true,
}, },
errorLogLevel: { errorLogLevel: {

View File

@ -24,6 +24,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE. 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 accessLogParamsDefault = 'buffer=512k flush=1m';
export const errorLogLevelDefault = 'warn'; export const errorLogLevelDefault = 'warn';