how to get `CF-IPCountry` header info of `X-Forwarded-For` header if it's present?

We use cloudflare workers for analytics and things of that nature. Sometimes we recommend that people send us analytics data via reverse proxy. This means that the CF-Connecting-IP ip address becomes that of the proxy server and X-Forwarded-For is the ip of the end user.

This all works great except CF-IPCountry becomes the geo location (Country, region, etc) of the reverse proxy and not the end user. So basically when we group our analytics data by country, it becomes incorrect.

Is there a way to rewrite worker headers to (if there is a X-Forwarded-For address, to use that to generate CF-IPCountry ?

I was looking for ways to modify request headers in docs here but not sure if what I am describing above is possible. Ref: https://developers.cloudflare.com/rules/transform/request-header-modification/
Cloudflare Docs
Use HTTP request header modification rules to manipulate the headers of HTTP requests sent to your origin server.
Was this page helpful?