vanful
vanful

Reputation: 112

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)

Upvotes: 0

Views: 1292

Answers (2)

scytale
scytale

Reputation: 1399

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).

Upvotes: 1

Michael C.
Michael C.

Reputation: 1457

You should be able to get the public IP address of traffics from X_FORWARDED_FOR variable.

https://aws.amazon.com/premiumsupport/knowledge-center/log-client-ip-load-balancer-apache/

You should print out the variable from Apache and see if you could receive the value correctly. Anything with 10.x is a private address.

Upvotes: 0

Related Questions