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 { 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

View File

@ -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`"
/>
</div>
</div>
@ -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`"
/>
</div>
</div>
@ -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: {

View File

@ -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';