Log real client IPs via Fly-Client-IP header (#130)
All checks were successful
Deploy Fly.io Proxy / deploy (push) Successful in 59s

## Summary
- Add `client_ip` field to the Fly.io nginx JSON log format, sourced from `Fly-Client-IP` header
- Extract `client_ip` in the Alloy pipeline so it's available as a parsed field in Loki
- Keeps `remote_addr` (the internal proxy IP) for debugging

Fixes: Grafana access logs for docs.eblu.me showing 172.16.11.178 for every request instead of real visitor IPs.

## Deployment and Testing
- [ ] Deploy updated fly.io proxy: `fly deploy` from `fly/` directory
- [ ] Verify in Grafana that new log lines include `client_ip` with real IPs
- [ ] Confirm `remote_addr` still shows the proxy IP (preserved for debugging)

Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/130
This commit is contained in:
Erich Blume 2026-02-09 11:02:06 -08:00
commit 3415cad38c
4 changed files with 4 additions and 1 deletions

View file

@ -24,6 +24,7 @@ loki.process "nginx" {
// Parse the JSON log line
stage.json {
expressions = {
client_ip = "client_ip",
status = "status",
method = "request_method",
host = "http_host",

View file

@ -13,6 +13,7 @@ http {
'{'
'"time":"$time_iso8601",'
'"remote_addr":"$remote_addr",'
'"client_ip":"$http_fly_client_ip",'
'"request_method":"$request_method",'
'"request_uri":"$request_uri",'
'"status":$status,'