How can we work with Geo-IP in local instance?
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
New contributor
add a comment |
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
New contributor
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago
add a comment |
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
New contributor
We are using Sitecore 7.2 in our project. We have a requirement that based on country Geo-IP home page needs to be redirected. Please help me in achieving this functionality in local instance.
geo-location
geo-location
New contributor
New contributor
edited 3 hours ago
Peter Procházka
4,8091841
4,8091841
New contributor
asked 3 hours ago
user4934user4934
61
61
New contributor
New contributor
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago
add a comment |
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago
add a comment |
3 Answers
3
active
oldest
votes
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
New contributor
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "664"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
user4934 is a new contributor. Be nice, and check out our Code of Conduct.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16156%2fhow-can-we-work-with-geo-ip-in-local-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
add a comment |
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
add a comment |
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
We are usually faking local IP address in this case.
We use querystring such as "?ipaddress={Fake_Ip_goes_here}" to inject faked ip address.
In your code, in place where you determine IP address, just add another condition if this query string is present, use value provided instead.
There are sites like this one https://www.nirsoft.net/countryip/ which will help you get proper IP for particular country to test whether redirection is working as expected.
Of course on production environment this is not desired so we usually introduce some kind of setting "EnableSettingIpAddressFromQueryString" which is on production set to False and we add another condition to upper one whether this setting is true so we only enable setting IP address from query string on non-production servers.
edited 1 hour ago
answered 3 hours ago
Peter ProcházkaPeter Procházka
4,8091841
4,8091841
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
add a comment |
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
2
2
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".
– josedbaez
1 hour ago
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
New contributor
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
New contributor
add a comment |
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
New contributor
You can add a processor to change request IP address locally in the analytics "createVisit" pipeline.
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<pipelines>
<createVisit>
<processor type="Sitecore.Foundation.Geolocation.Pipelines.Testing.ChangeIP, Sitecore.Foundation.Geolocation"
patch:after="processor[@type='Sitecore.Analytics.Pipelines.CreateVisits.XForwardedFor, Sitecore.Analytics']">
</processor>
</createVisit>
</pipelines>
<settings>
<setting name="Foundation.Geolocation.Testing.IP" value="77.73.57.78"/>
</settings>
</sitecore>
</configuration>
namespace Sitecore.Foundation.Geolocation.Pipelines.Testing
{
public class ChangeIP : CreateVisitProcessor
{
public override void Process(CreateVisitArgs args)
{
Assert.ArgumentNotNull((object)args, "args");
string ip = new IPAddress(Tracker.Current.Interaction.Ip).ToString();
if (ip != "0.0.0.0" && ip != "127.0.0.1")
{
return;
}
IPAddress address;
if (IPAddress.TryParse(Configuration.Settings.GetSetting("Foundation.Geolocation.Testing.IP"), out address))
{
args.Interaction.Ip = address.GetAddressBytes();
}
}
}
}
New contributor
edited 1 hour ago
Gatogordo
11.3k21656
11.3k21656
New contributor
answered 3 hours ago
Andrei AkonnikauAndrei Akonnikau
314
314
New contributor
New contributor
add a comment |
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
add a comment |
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
One way I've done this before is to use ngrok http tunneling https://ngrok.com, and then use a VPN service to imitate the connection. This way works for all web applications, not just sitecore.
I think this is a great way for non technical people (eg stakeholders) to test the functionality without mucking around with anything.
answered 1 hour ago
Vincent LuiVincent Lui
946
946
add a comment |
add a comment |
user4934 is a new contributor. Be nice, and check out our Code of Conduct.
user4934 is a new contributor. Be nice, and check out our Code of Conduct.
user4934 is a new contributor. Be nice, and check out our Code of Conduct.
user4934 is a new contributor. Be nice, and check out our Code of Conduct.
Thanks for contributing an answer to Sitecore Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f16156%2fhow-can-we-work-with-geo-ip-in-local-instance%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Be aware of first request issue: kb.sitecore.net/articles/320734.
– josedbaez
1 hour ago