homek8s/infrastructure/networking/gateway/gatewayclass-config.yaml

52 lines
2.3 KiB
YAML
Raw Permalink Normal View History

# Envoy access logging for every Gateway served by the Cilium GatewayClass.
#
# Finding F7 (2026-11-27 netsec audit): cilium-envoy emitted no request-level
# record at all, so the design's HTTP attack-shape rules (§4d: traversal,
# `union select`, `%00`, .env/.git probes, high-rate 401/403 per client,
# scanner user-agents) had no input stream.
#
# Cilium 1.20 renders this into the Gateway listeners' HTTP connection manager
# and writes one JSON line per request to the cilium-envoy container's stdout,
# i.e. /var/log/pods/kube-system_cilium-envoy-*/cilium-envoy/*.log, which the
# node log store (Alloy -> Loki) already tails.
#
# Deliberately NOT logged:
# * no debug/trace Envoy application logging (disk is the constraint here);
# * no request/response headers wholesale and no bodies -- Authorization,
# Cookie and Set-Cookie therefore never reach disk. Only the named fields
# below are emitted, each an explicit command operator.
#
# `client_ip` is the real client identity: Envoy is hostNetwork, so the raw
# peer is cloudflared on the Pi (10.10.0.1). Cloudflare sets CF-Connecting-IP
# and cloudflared forwards it; `peer` and `x_forwarded_for` are kept so a
# missing/forged CF-Connecting-IP is visible rather than silently trusted.
apiVersion: cilium.io/v2alpha1
kind: CiliumGatewayClassConfig
metadata:
name: cilium
namespace: kube-system
spec:
description: Cilium GatewayClass with HTTP access logging (netsec F7)
telemetry:
accessLogs:
- format: JSON
targets:
- HTTP
json:
gateway: "%CILIUM_GATEWAY_NAMESPACE%/%CILIUM_GATEWAY_NAME%"
start_time: "%START_TIME%"
method: "%REQUEST_HEADER(:METHOD)%"
path: "%REQUEST_HEADER(X-ENVOY-ORIGINAL-PATH?:PATH)%"
protocol: "%PROTOCOL%"
response_code: "%RESPONSE_CODE%"
response_flags: "%RESPONSE_FLAGS%"
duration_ms: "%DURATION%"
bytes_received: "%BYTES_RECEIVED%"
bytes_sent: "%BYTES_SENT%"
authority: "%REQUEST_HEADER(:AUTHORITY)%"
client_ip: "%REQUEST_HEADER(CF-CONNECTING-IP)%"
x_forwarded_for: "%REQUEST_HEADER(X-FORWARDED-FOR)%"
peer: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%"
user_agent: "%REQUEST_HEADER(USER-AGENT)%"
cf_ray: "%REQUEST_HEADER(CF-RAY)%"
upstream_host: "%UPSTREAM_HOST%"