Use log_append for upstream details

This commit is contained in:
Steffen Busch 2024-06-01 23:55:16 +02:00 committed by GitHub
parent ca9ce7b2b5
commit b9237a5a81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -37,3 +37,22 @@ example.com {
}
}
```
Display in the logs, which reverse proxy upstream was effectively used (either `node1:80`, `node2:80` or `node3:80`) and
the time spent proxying to the upstream in milliseconds as well as how long it took the proxy upstream to write the response header:
```caddy
example.com {
log
handle {
reverse_proxy node1:80 node2:80 node3:80 {
header_up Host {upstream_hostport}
lb_policy random_choose 2
}
log_append upstream-host "{http.reverse_proxy.upstream.host}"
log_append upstream-duration-ms "{http.reverse_proxy.upstream.duration_ms}"
log_append upstream-latency-ms "{http.reverse_proxy.upstream.latency_ms}"
}
}
```