How can we work with Geo-IP in local instance?












1















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.










share|improve this question









New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Be aware of first request issue: kb.sitecore.net/articles/320734.

    – josedbaez
    1 hour ago
















1















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.










share|improve this question









New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





















  • Be aware of first request issue: kb.sitecore.net/articles/320734.

    – josedbaez
    1 hour ago














1












1








1








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.










share|improve this question









New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 3 hours ago









Peter Procházka

4,8091841




4,8091841






New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 3 hours ago









user4934user4934

61




61




New contributor




user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






user4934 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • 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





Be aware of first request issue: kb.sitecore.net/articles/320734.

– josedbaez
1 hour ago










3 Answers
3






active

oldest

votes


















3














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.






share|improve this answer





















  • 2





    I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".

    – josedbaez
    1 hour ago



















1














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();
}
}
}
}





share|improve this answer










New contributor




Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




























    0














    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.






    share|improve this answer























      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.










      draft saved

      draft discarded


















      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









      3














      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.






      share|improve this answer





















      • 2





        I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".

        – josedbaez
        1 hour ago
















      3














      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.






      share|improve this answer





















      • 2





        I can't remember in which version it was added but I usually use setting "Analytics.ForwardedRequestHttpHeader".

        – josedbaez
        1 hour ago














      3












      3








      3







      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.






      share|improve this answer















      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.







      share|improve this answer














      share|improve this answer



      share|improve this answer








      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














      • 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











      1














      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();
      }
      }
      }
      }





      share|improve this answer










      New contributor




      Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























        1














        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();
        }
        }
        }
        }





        share|improve this answer










        New contributor




        Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.























          1












          1








          1







          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();
          }
          }
          }
          }





          share|improve this answer










          New contributor




          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.










          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();
          }
          }
          }
          }






          share|improve this answer










          New contributor




          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          share|improve this answer



          share|improve this answer








          edited 1 hour ago









          Gatogordo

          11.3k21656




          11.3k21656






          New contributor




          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.









          answered 3 hours ago









          Andrei AkonnikauAndrei Akonnikau

          314




          314




          New contributor




          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.





          New contributor





          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.






          Andrei Akonnikau is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.























              0














              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.






              share|improve this answer




























                0














                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.






                share|improve this answer


























                  0












                  0








                  0







                  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.






                  share|improve this answer













                  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.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered 1 hour ago









                  Vincent LuiVincent Lui

                  946




                  946






















                      user4934 is a new contributor. Be nice, and check out our Code of Conduct.










                      draft saved

                      draft discarded


















                      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.




                      draft saved


                      draft discarded














                      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





















































                      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







                      Popular posts from this blog

                      الفوسفات في المغرب

                      Four equal circles intersect: What is the area of the small shaded portion and its height

                      جامعة ليفربول