Search code examples
amazon-web-serviceslaravel-5amazon-ec2amazon-elastic-beanstalkmaxmind

AWS-ELB -> GEOIP -> MAXMIND -> Laravel


Were trying to serve people from multiple countries the right language on our Website. We have added GeoIP in Laravel and also the maxmind package.

Whatever we try we get everytime issues as Error 500: The IP address '10.2.1.211' is a reserved IP address

We first tried to make in apache a redirect X_FORWARDED_FOR but it isn't working still.

Can someone assist us and tell us exactly how to solve it?

Our Envoirements: AWS: Cloundfront, ELB, Ec2, Laravel 5.5, Maxmind (for GeoIP)


Solution

  • It would appear that you can configure Cloudfront to provide an http header CloudFront-Viewer-Country which will contain the ISO country code for your visitor. This will be faster and simpler to use than Maxmind.

    e.g. $visitorCountryCode = isset($_SERVER['CloudFront-Viewer-Country']) ? $_SERVER['CloudFront-Viewer-Country'] : '';

    Is your error 500 is during testing only? If testing with devices directly connected to your site/intranet then try accessing via a browser connected through an Internet Service provider instead (a "direct" or intranet connection could well have a "reserved" IP address).