express-pino-logger
express-pino-logger copied to clipboard
how to log cdn cloudflare ip address?
req.remoteAddress does not working, how to change to req.header('x-real-ip'), mywebsite is running behind cloudflare cdn.
serializers: {
req: function requestSerializer(req) {
return {
id: req.id,
method: req.method,
url: req.url,
remoteAddress: req.header('x-real-ip') || req.connection.remoteAddress,
remotePort: req.remotePort,
body: req.raw.body,
};
},
},
isn't the snippet you pasted enough?
I believe CloudFlare forwards the connecting clients IP via the CF-Connecting-IP
header rather than the X-Real-IP
header.