Geo info on reverse proxy

Hello, I have a question about the geo object while using a reverse proxy. Currently, it’s pulling the geo data based on the nginx server IP that is proxying to Netlify. (I know this isn’t ideal, but we are stuck with the current setup for multiple reasons)

example of the edge function: countrytoggle.js · GitHub

I have the real client IP coming in from the “X-Forwarded-For” header. Is there a way to intercept the request, and set the IP to that so the geo object is based on the real client IP? Or will I have to use a third party api to retrieve geo data based on that?

Thank you!

Hi @sbennett,

Thanks for reaching out and welcome to Netlify Support Forums!

There’s an example of an Edge Function getting Geo location for a users here:

Does this help!

Hello @Melvin !

Thanks for the response!

Unfortunately, the geolocation picks up the IP address from our NGINX server. I wasn’t sure if there was a way to update the IP address the geolocation uses to the real client ID using the X-Forwarded-For header

As long as that header exists as one of the request headers, you should be able to get it from the Edge Function: