add docker ip

This commit is contained in:
dongwei 2019-02-28 14:20:42 +08:00
parent 436a084581
commit 445f9dd037
2 changed files with 92 additions and 65 deletions

View File

@ -15,12 +15,21 @@ class InternalApi
app()->configure('internal_api'); app()->configure('internal_api');
} }
private function isClientIPPermitted ($ip) { private function isClientIPPermitted($ip)
{
if (!app()->environment('production', 'staging')) { if (!app()->environment('production', 'staging')) {
return true; return true;
} }
if (Str::startsWith($ip, [ if (Str::startsWith($ip, [
'127.0.0.', '192.168.', '10.0.', '127.0.0.1',
//局域网
'192.168.',
//vpc
'10.0.',
//pod network
'172.20.',
//北京办公区
'172.16.'
])) { ])) {
return true; return true;
} }

View File

@ -2,8 +2,26 @@
namespace PdInternalApi; namespace PdInternalApi;
use Illuminate\Http\Request;
class ServiceProvider extends \Illuminate\Support\ServiceProvider class ServiceProvider extends \Illuminate\Support\ServiceProvider
{ {
public function boot(){
Request::setTrustedProxies([
//pod network
'172.20.0.0/16',
//vpc
'10.0.0.0/16',
//local
'127.0.0.1',
//北京办公区
'172.16.0.0/16',
//aliyun slb
'100.116.0.0/16',
], Request::HEADER_X_FORWARDED_ALL);
}
/** /**
* Register any application services. * Register any application services.
* *