mirror of
https://github.com/digitalocean/nginxconfig.io.git
synced 2025-11-05 18:56:09 +08:00
* #116 Log Cloudflare headers * #116 Log Cloudflare headers * #116 Log Cloudflare headers * #163 Fix linting * Update src/nginxconfig/generators/conf/website.conf.js Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk> * Update src/nginxconfig/generators/conf/website.conf.js Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk> * Update src/nginxconfig/generators/conf/website.conf.js Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk> * Update src/nginxconfig/generators/conf/nginx.conf.js Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk> * Remove extra div + incorrect if check, revert linebreak removal * handle custom log formats as an array * Update src/nginxconfig/generators/conf/nginx.conf.js Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk> * remove curly braces, move default log format array definition inside if statement Co-authored-by: Matt (IPv4) Cowley <me@mattcowley.co.uk>
This commit is contained in:
@@ -73,8 +73,44 @@ export default (domains, global) => {
|
||||
config.http.push(['include', 'mime.types']);
|
||||
config.http.push(['default_type', 'application/octet-stream']);
|
||||
|
||||
// Append Cloudflare request headers to the default log format
|
||||
if (global.logging.cloudflare.computed) {
|
||||
config.http.push(['# Log Format', '']);
|
||||
|
||||
// Define default log format as an array
|
||||
let logging = ['$remote_addr', '-', '$remote_user', '[$time_local]',
|
||||
'"$request"', '$status', '$body_bytes_sent',
|
||||
'"$http_referer"', '"$http_user_agent"'];
|
||||
|
||||
if (global.logging.cfRay.computed)
|
||||
logging.push('$http_cf_ray');
|
||||
|
||||
if (global.logging.cfConnectingIp.computed)
|
||||
logging.push('$http_cf_connecting_ip');
|
||||
|
||||
if (global.logging.xForwardedFor.computed)
|
||||
logging.push('$http_x_forwarded_for');
|
||||
|
||||
if (global.logging.xForwardedProto.computed)
|
||||
logging.push('$http_x_forwarded_proto');
|
||||
|
||||
if (global.logging.trueClientIp.computed)
|
||||
logging.push('$http_true_client_ip');
|
||||
|
||||
if (global.logging.cfIpCountry.computed)
|
||||
logging.push('$http_cf_ipcountry');
|
||||
|
||||
if (global.logging.cfVisitor.computed)
|
||||
logging.push('$http_cf_visitor');
|
||||
|
||||
if (global.logging.cdnLoop.computed)
|
||||
logging.push('$http_cdn_loop');
|
||||
|
||||
config.http.push(['log_format', `cloudflare '${logging.join(' ')}'`]);
|
||||
}
|
||||
|
||||
config.http.push(['# Logging', '']);
|
||||
config.http.push(['access_log', global.logging.accessLog.computed.trim() || 'off']);
|
||||
config.http.push(['access_log', (global.logging.accessLog.computed.trim() + (global.logging.cloudflare.computed ? ' cloudflare' : '')) || 'off']);
|
||||
config.http.push(['error_log', global.logging.errorLog.computed.trim() || '/dev/null']);
|
||||
|
||||
if (global.security.limitReq.computed) {
|
||||
|
||||
@@ -184,7 +184,7 @@ export default (domain, domains, global) => {
|
||||
serverConfig.push(['# logging', '']);
|
||||
|
||||
if (domain.logging.accessLog.computed)
|
||||
serverConfig.push(['access_log', getAccessLogDomainPath(domain, global)]);
|
||||
serverConfig.push(['access_log', getAccessLogDomainPath(domain, global) + (global.logging.cloudflare.computed ? ' cloudflare' : '')]);
|
||||
|
||||
if (domain.logging.errorLog.computed)
|
||||
serverConfig.push(['error_log', getErrorLogDomainPath(domain, global)]);
|
||||
|
||||
Reference in New Issue
Block a user