Could be you are running locally, in which case your local IP for requests will be 127.0.0.1, and so not located in a particular country. If that's the issue, try setting the config value testFixedIp documented here.
That should allow you test locally for various known IPs of different countries.
When you deploy to a server it should pick up the IP of the client's request and work as you'd expect.
CF-Connecting-IP
To provide the client (visitor) IP address for every request to the origin, Cloudflare adds the CF-Connecting-IP header.
"CF-Connecting-IP: A.B.C.D"
Where A.B.C.D is the client's IP address, also known as the original visitor IP address.
X-Forwarded-For
X-Forwarded-For is a well-established HTTP header used by proxies, including Cloudflare, to pass along other IP addresses in the request. This is often the same as CF-Connecting-IP, but there may be multiple layers of proxies in a request path.
Two possible outcomes.
First, if there was no existing "X-Forwarded-For" header in the request sent to Cloudflare, then the header would have an identical value to the CF-Connecting-IP header, like this:
"X-Forwarded-For: A.B.C.D"
where A.B.C.D is the client's IP address, also known as the original visitor IP address.
Second, if there was an "X-Forwarded-For" header present in the request sent to Cloudflare, Cloudflare appends the client's IP to its value, as the last in the list.
"X-Forwarded-For: A.B.C.D[,X.X.X.X,Y.Y.Y.Y,]"
where A.B.C.D is the client's IP address, also known as the original visitor IP address. X.X.X.X and Y.Y.Y.Y in this example are IP addresses along the route in the header value.
personalisation Groups Country Matching
Just getting started with personalisation Groups - Ive gotten the time based personalisation to work i.e.
@Umbraco.MatchesGroup("Weekday Morning Visitors");
Just having a bit of difficulty getting the country matching one to work. I ve created a personalisation called "country match"
Ive downloaded the GeoLite2-Country.mmdb into the app data folder.
And added the following in appSettings in my web.config :
However @Umbraco.MatchesGroup("Country Match"); always returns false.
The personalisation I am looking to do is fairly basic i.e. if in Ireland show this pic if in Uk show this pic etc.
Any help or pointers would be fantastic.
Could be you are running locally, in which case your local IP for requests will be 127.0.0.1, and so not located in a particular country. If that's the issue, try setting the config value
testFixedIp
documented here.That should allow you test locally for various known IPs of different countries.
When you deploy to a server it should pick up the IP of the client's request and work as you'd expect.
Andy
I try now and let you know. Thank you for coming back so quickly.
Thanks so much :-) really appreciate the quick response time.
Is there any support for CloudFlare or one has to do custom handling of the real visitor IP in case of CloudFlare?
Not specifically tested with Cloudflare no but as you can see here, am checking a number of header values to determine the requesting IP.
Bear in mind that CDN caching (by URL) likely won't play nicely with server-side personalisation (i.e. returning different content for the same URL).
Andy
Thanks for the prompt reply and pointer.
If the header CF-Connecting-IP could be added that would be even better, as I see CloudFlare support for X-Forwarded-For is rather different, where it appends originating ip if the header was present. From Cloudflare help @ https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-
Would you like to try the latest version - 0.3.1? I've just released it and included this additional header.
Andy
That looks great, will try the latest version.......
Thanks Andy!
is working on a reply...