Log real client IPs via Fly-Client-IP header #130
4 changed files with 4 additions and 1 deletions
|
|
@ -242,7 +242,7 @@ data:
|
|||
"wrapLogMessage": false
|
||||
},
|
||||
"targets": [
|
||||
{ "datasource": { "type": "loki", "uid": "loki" }, "expr": "{instance=\"flyio-proxy\", job=\"flyio-nginx\"} |= \"docs.eblu.me\"", "refId": "A" }
|
||||
{ "datasource": { "type": "loki", "uid": "loki" }, "expr": "{instance=\"flyio-proxy\", job=\"flyio-nginx\"} |= \"docs.eblu.me\" | json | line_format \"{{.client_ip}} {{.request_method}} {{.request_uri}} {{.status}} cache={{.upstream_cache_status}} {{.request_time}}s\"", "refId": "A" }
|
||||
],
|
||||
"title": "Recent Access Logs",
|
||||
"type": "logs"
|
||||
|
|
|
|||
1
docs/changelog.d/fix-real-client-ip-logging.bugfix.md
Normal file
1
docs/changelog.d/fix-real-client-ip-logging.bugfix.md
Normal file
|
|
@ -0,0 +1 @@
|
|||
Log real client IPs in Fly.io proxy access logs using Fly-Client-IP header instead of showing the internal proxy address.
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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,'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue