Trying to get the clients' location using it's ip address on umbraco cloud using
Request.UserHostAddress
On a dedicated server it returns the clients' IP. However on Umbraco Cloud, I get a 172.XX.XXX.XXX IP.
After I check the IP location for some countries it does provide the right location (Example: Mauritius), but for some it displays the wrong information (Example Reunion)
I just want to note here that an IP address is not a reliable way to get someone's country and it really doesn't tell you what language you should show people.
For me, I am from the Netherlands and speak Dutch and English. I live in Denmark though and get served sites in Danish all the time, even though I have limited understanding of it.
My browser, however tells the site: hi there, please talk to me in en-US if you can or otherwise nl-NL.
So all that to say: I would encourage you to look at the accept-language header in the request, instead of finding the possible location of the IP address and forcing a language people don't necessarily want.
Thanks for your reply. I am currently trying to capture the location of the client as we are looking to get the country where the user is accessing the website to provide specific offers and rates applicable per destination/country.
Which is why we installed maxmind geoip on our development server, which was previously cloned from the cloud, and pushed the extension files to Umbraco cloud.
On our test server, we get the correct location and therefore can provide the correct rates and offers based on where the user is connecting, however while testing on the cloud environment we cannot retrieve the correct IP data for Reunion island. We do however get the correct data for Mauritius.
Sure, that's a use case I didn't think of. I know that Cloud sites are behind Cloudflare so that probably has something to do with it. I don't know if you can get the end-user's IP address, but worth asking the Cloud support team (us the chat bubble in the Cloud portal - https://umbraco.io/).
Localization on cloud
Hi all,
Trying to get the clients' location using it's ip address on umbraco cloud using
On a dedicated server it returns the clients' IP. However on Umbraco Cloud, I get a 172.XX.XXX.XXX IP. After I check the IP location for some countries it does provide the right location (Example: Mauritius), but for some it displays the wrong information (Example Reunion)
Thanks
I just want to note here that an IP address is not a reliable way to get someone's country and it really doesn't tell you what language you should show people.
For me, I am from the Netherlands and speak Dutch and English. I live in Denmark though and get served sites in Danish all the time, even though I have limited understanding of it.
My browser, however tells the site: hi there, please talk to me in
en-US
if you can or otherwisenl-NL
.So all that to say: I would encourage you to look at the
accept-language
header in the request, instead of finding the possible location of the IP address and forcing a language people don't necessarily want.Hi Sebastiaan,
Thanks for your reply. I am currently trying to capture the location of the client as we are looking to get the country where the user is accessing the website to provide specific offers and rates applicable per destination/country.
Which is why we installed maxmind geoip on our development server, which was previously cloned from the cloud, and pushed the extension files to Umbraco cloud.
On our test server, we get the correct location and therefore can provide the correct rates and offers based on where the user is connecting, however while testing on the cloud environment we cannot retrieve the correct IP data for Reunion island. We do however get the correct data for Mauritius.
Sure, that's a use case I didn't think of. I know that Cloud sites are behind Cloudflare so that probably has something to do with it. I don't know if you can get the end-user's IP address, but worth asking the Cloud support team (us the chat bubble in the Cloud portal - https://umbraco.io/).
Looks like you could use the
CF-Connecting-IP
header to look for the origin IP (I found a hint here: https://our.umbraco.com/documentation/umbraco-cloud/Security/#restrict-backoffice-access-using-ip-filtering) and it looks like this is the answer for any CloudFlare user: https://community.cloudflare.com/t/transform-rule-to-restore-x-forwarded-for/372316/2Hi Sebastiaan,
That works great.
I can now get client's IP instead of the Proxy.
is working on a reply...