Open MrEhsanEllahi opened 5 years ago
i'm tryin in laravel 5.8 in Guatemala, and always return default, but if pass an IP from amazon server return the ip info
Check your logfile in storage/logs/geoip.log
. At first I thought it was a bug, apparently I detected the wrong IP address (I detected my own local ip address), then Geoip will return default/fallback data because the error on ip address.
@naorellana Mostly when you are working on AWS servers and want to receive real user's ip you should check X-Forwarded-For or restrict all users and allow them to use your page if they have REMOTE_ADDR in header. Also if you are using Laravel 6.0 and above they have added TrustedProxy in the main package so you should just 'proxies' => '**' in trustedproxy.php
I am using this package in laravel 5.8 project. I am using default geoip api. But it always returns the default value. Any solution, Code is below.
namespace App\Http\Controllers;
use Illuminate\Http\Request; use \Torann\GeoIP\GeoIP;
class HomeController extends Controller { // public function index(){ $ip = geoip()->getClientIP(); $arr_ip = geoip()->getLocation($ip); return view('index')->with('arr_ip', $arr_ip); } }