node-red-dashboard icon indicating copy to clipboard operation
node-red-dashboard copied to clipboard

Option to get `socketIp` via custom headers

Open arturv2000 opened this issue 1 year ago • 3 comments

Description

Hi

Regarding the field socketIp that is added to each message in the _client property. If using reverse proxys the client IP is always 127.0.0.1 .

Would it be possible to have a dashboard setting to indicate if we want to use the default conn.handshake?.address or to get it by some header like conn.handshake.headers["x-forwarded-for"]?

Cloudfare for example uses header CF-Connecting-IP.

Have you provided an initial effort estimate for this issue?

I am no FlowFuse team member

arturv2000 avatar Jun 25 '24 15:06 arturv2000

This feels like something that would live in the Node-RED settings.js, rather than a UI-surfaced configuration

joepavitt avatar Jun 26 '24 08:06 joepavitt

Yes, it can be something in settings, like a custom callback to be called on io.on("connection", (socket), like the example here -> https://socket.io/how-to/get-the-ip-address-of-the-client. It can be defined in the same way as httpAdminMiddleware for example, but eventually in a section dedicated to dashboard.

arturv2000 avatar Jun 26 '24 09:06 arturv2000

Alternatively socketIp could always be primarily set by headers like X-Forwarded-For and X-Real-IP. Only if those are missing, use the handshake address? Would this affect existing flows?

ignitedPotato avatar Aug 06 '25 07:08 ignitedPotato