FlowFuse / node-red-dashboard

https://dashboard.flowfuse.com
Apache License 2.0
195 stars 46 forks source link

Option to get `socketIp` via custom headers #1028

Open arturv2000 opened 3 months ago

arturv2000 commented 3 months ago

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

joepavitt commented 3 months ago

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

arturv2000 commented 3 months ago

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.