Is it possible to use Geolocation with proxy pass?


#1

I have a website that is using cf-ipcountry header to detect client ip country.
I would need to proxy pass to this website from another server.
Here is my sample nginx config for proxy pass:

 server {
    listen       80;
    server_name  ...;

    location /test {
        proxy_pass http://{domain-handled-by-cloud-flare-with-geolocation};
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

Proxy pass is working but in this case cf-ipcountry header is always set to country from proxy server location, not from client location that is making request.

Domain for proxy server is not on CloudFlare so i can’t pass cf-ipcountry header myself.

Is it possible to pass somehow client ip from proxy server to CloudFlare so geolocation would give me ip country form client location?


#2

Hi @adam187,
Did you check the Cloudflare IP Geolocation?
You can enable IP Geolocation to have Cloudflare geolocate visitors to your website and pass the country code to you in ISO 3166-1 Alpha 2 format.

You will find the IP Geolocation option under the ‘Network’ section of the dashboard.
I’m not 100% sure if that solves your problem but take a look here