Is the "Client-IP" header going to be supported long term?

I’ve seen that X-Forwarded-For is not supported by Netlify and you recommend alternative headers.

Specifically, looks like you provide three options:

X-Nf-Client-Connection-Ip
X-Bb-Ip
Client-Ip

We would like to use the client-ip header for our logging - is this a header you are supporting long term?

Hi there,

We make no guarantees on anything except “X-Nf-Client-Connection-Ip”. Please use that one instead!

Many other companies seem to have settled on true-client-ip as a header for this purpose - is this something you could support?

Nope! We’ll be using the header names we have in place already :slight_smile:

I get that, but it makes things very difficult for our (Netlify and Discourse) common customers.

We need to tell customers with proxies in front of their Discourse installation to scrub certain headers from requests before they forward them to us and we really don’t want that list to grow.

Would you consider adding support for the industry standard x-forwarded-for or the sort-of-emerging true-client-ip?

EDIT: we’ve adjusted how we’re doing things such that this is not a huge problem for us

Great to hear! We use x-forwarded-for internally, so no can do on that one. Could you link me to the details on the “emerging standard” you reference? Our team would be happy to take a look at it, I just hadn’t heard of it before so not sure where you’ve seen it :slight_smile:

This type of detail would be really useful in the main Functions section of the docs. Can it be added please?

2 Likes

Hi there, could you be a bit more specific on which type of detail you feel should be added? thanks!

Specifically that X-Nf-Client-Connection-Ip is available to our code, what it represents, and so forth.

thanks for clarifying, i’ll do some checking!

2 posts were split to a new topic: Seeing inconsistency with client-ip: headers in HTTP request proxied from Netlify

Seems event.headers['client-ip'] has started to be undefined some time this week. I still could not find any documentation on X-Nf-Client-Connection-Ip via Google, but fortunately this thread appeared.On the other hand, event.headers['X-Nf-Client-Connection-Ip'] is also undefined for me right now, so not sure how to proceed…

Update: Seems using lowercase event.headers['x-nf-client-connection-ip'] works for now.

Update 2: Ths smells related, although of course it should not touch any of this: Upcoming change: Stripping exposed Netlify headers from function and proxy requests

1 Like

Old thread, but something I wanted to note: ‘client-ip’ works when hosting locally with netlify dev from the CLI. In that case, though, ’ x-nf-client-connection-ip’ does not. However, once deployed to web, ‘client-ip’ does not work and ’ x-nf-client-connection-ip’ does.

Here is my function:

import { Handler, HandlerEvent, HandlerContext } from "@netlify/functions";

const handler: Handler = async (event: HandlerEvent, context: HandlerContext) => {
    console.log(event.headers['x-nf-client-connection-ip']);

    return {
        statusCode: 200,
    };
};

export { handler };

Should these be made consistent?

I don’t believe CLI can have x-nf- headers, as those are something added by Netlify servers. Since the request is not going through Netlify servers, maybe adding that would not be ideal - but I see your complaint. Mind filing an issue on the CLI repo so the devs can decide what’s the best path forward?