Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

how to log cdn cloudflare ip address? #57

Open
epubreader opened this issue Feb 20, 2021 · 2 comments
Open

how to log cdn cloudflare ip address? #57

epubreader opened this issue Feb 20, 2021 · 2 comments

Comments

@epubreader
Copy link

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,
                };
            },
        },
@mcollina
Copy link
Member

isn't the snippet you pasted enough?

@James11T
Copy link

James11T commented May 4, 2022

I believe CloudFlare forwards the connecting clients IP via the CF-Connecting-IP header rather than the X-Real-IP header.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants