Log Cloudflare headers (#116) (#183)

* #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:
Faiz Azhar
2020-10-28 02:11:53 +08:00
committed by GitHub
parent ae322cf2c5
commit 3b00bda80e
4 changed files with 209 additions and 2 deletions

View File

@@ -77,6 +77,88 @@ THE SOFTWARE.
</div>
</div>
</div>
<div class="field is-horizontal is-aligned-top">
<div class="field-label">
<label class="label">{{ i18n.templates.globalSections.logging.logformat }}</label>
</div>
<div class="field-body">
<div class="field">
<div v-if="cloudflareEnabled" :class="`control${cloudflareChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cloudflare" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.enableCloudflare }}
</PrettyCheck>
</div>
</div>
<div v-if="cfRayEnabled" :class="`control${cfRayChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cfRay" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.cfRay }}
</PrettyCheck>
</div>
</div>
<div v-if="cfConnectingIpEnabled" :class="`control${cfConnectingIpChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cfConnectingIp" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.cfConnectingIp }}
</PrettyCheck>
</div>
</div>
<div v-if="xForwardedForEnabled" :class="`control${xForwardedForChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="xForwardedFor" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.xForwardedFor }}
</PrettyCheck>
</div>
</div>
<div v-if="xForwardedProtoEnabled" :class="`control${xForwardedProtoChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="xForwardedProto" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.xForwardedProto }}
</PrettyCheck>
</div>
</div>
<div v-if="trueClientIpEnabled" :class="`control${trueClientIpChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="trueClientIp" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.trueClientIp }}
</PrettyCheck>
</div>
</div>
<div v-if="cfIpCountryEnabled" :class="`control${cfIpCountryChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cfIpCountry" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.cfIpCountry }}
</PrettyCheck>
</div>
</div>
<div v-if="cfVisitorEnabled" :class="`control${cfVisitorChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cfVisitor" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.cfVisitor }}
</PrettyCheck>
</div>
</div>
<div v-if="cdnLoopEnabled" :class="`control${cdnLoopChanged ? ' is-changed' : ''}`">
<div class="checkbox">
<PrettyCheck v-model="cdnLoop" class="p-default p-curve p-fill p-icon">
<i slot="extra" class="icon fas fa-check"></i>
{{ i18n.templates.globalSections.logging.cdnLoop }}
</PrettyCheck>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
@@ -99,6 +181,42 @@ THE SOFTWARE.
default: false,
enabled: true,
},
cloudflare: {
default: false,
enabled: true,
},
cfRay: {
default: true,
enabled: false,
},
cfConnectingIp: {
default: true,
enabled: false,
},
xForwardedFor: {
default: false,
enabled: false,
},
xForwardedProto: {
default: false,
enabled: false,
},
trueClientIp: {
default: false,
enabled: false,
},
cfIpCountry: {
default: false,
enabled: false,
},
cfVisitor: {
default: false,
enabled: false,
},
cdnLoop: {
default: false,
enabled: false,
},
};
export default {
@@ -118,5 +236,48 @@ THE SOFTWARE.
};
},
computed: computedFromDefaults(defaults, 'logging'), // Getters & setters for the delegated data
watch: {
// Show Cloudflare header options if Cloudflare is enabled
'$props.data.cloudflare': {
handler(data) {
if (data.computed) {
this.$props.data.cfRay.enabled = true;
this.$props.data.cfRay.computed = this.$props.data.cfRay.value;
this.$props.data.cfConnectingIp.enabled = true;
this.$props.data.cfConnectingIp.computed = this.$props.data.cfConnectingIp.value;
this.$props.data.xForwardedFor.enabled = true;
this.$props.data.xForwardedFor.computed = this.$props.data.xForwardedFor.value;
this.$props.data.xForwardedProto.enabled = true;
this.$props.data.xForwardedProto.computed = this.$props.data.xForwardedProto.value;
this.$props.data.trueClientIp.enabled = true;
this.$props.data.trueClientIp.computed = this.$props.data.trueClientIp.value;
this.$props.data.cfIpCountry.enabled = true;
this.$props.data.cfIpCountry.computed = this.$props.data.cfIpCountry.value;
this.$props.data.cfVisitor.enabled = true;
this.$props.data.cfVisitor.computed = this.$props.data.cfVisitor.value;
this.$props.data.cdnLoop.enabled = true;
this.$props.data.cdnLoop.computed = this.$props.data.cdnLoop.value;
} else {
this.$props.data.cfRay.enabled = false;
this.$props.data.cfRay.computed = false;
this.$props.data.cfConnectingIp.enabled = false;
this.$props.data.cfConnectingIp.computed = false;
this.$props.data.xForwardedFor.enabled = false;
this.$props.data.xForwardedFor.computed = false;
this.$props.data.xForwardedProto.enabled = false;
this.$props.data.xForwardedProto.computed = false;
this.$props.data.trueClientIp.enabled = false;
this.$props.data.trueClientIp.computed = false;
this.$props.data.cfIpCountry.enabled = false;
this.$props.data.cfIpCountry.computed = false;
this.$props.data.cfVisitor.enabled = false;
this.$props.data.cfVisitor.computed = false;
this.$props.data.cdnLoop.enabled = false;
this.$props.data.cdnLoop.computed = false;
}
},
deep: true,
},
},
};
</script>