diff --git a/src/Middleware/Security.php b/src/Middleware/Security.php index 5007b02..308efb3 100644 --- a/src/Middleware/Security.php +++ b/src/Middleware/Security.php @@ -45,9 +45,15 @@ class Security } if (Str::startsWith($ip, [ - '127.0.0.', + '127.0.0.1', + //局域网 '192.168.', + //vpc '10.0.', + //pod network + '172.20.', + //北京办公区 + '172.16.' ])) { return true; } diff --git a/src/Providers/BaseServiceProvider.php b/src/Providers/BaseServiceProvider.php index f662a43..ea088c7 100644 --- a/src/Providers/BaseServiceProvider.php +++ b/src/Providers/BaseServiceProvider.php @@ -3,14 +3,26 @@ namespace JsonRpc\Providers; +use Illuminate\Http\Request; use Illuminate\Support\ServiceProvider; -use JsonRpc\Exception\RpcServerException; use Monolog\Handler\StreamHandler; use Monolog\Logger; class BaseServiceProvider extends ServiceProvider { + public function boot(){ + Request::setTrustedProxies([ + //pod network + '172.20.0.0/16', + //vpc + '10.0.2.0/16', + //local + '127.0.0.1', + //北京办公区 + '172.16.100.0/16' + ], Request::HEADER_X_FORWARDED_ALL); + } protected function setupConfig() { diff --git a/src/Providers/LumenServerServiceProvider.php b/src/Providers/LumenServerServiceProvider.php index 5290194..a6625a5 100644 --- a/src/Providers/LumenServerServiceProvider.php +++ b/src/Providers/LumenServerServiceProvider.php @@ -25,6 +25,7 @@ class LumenServerServiceProvider extends BaseServiceProvider public function boot() { + parent::boot(); $this->app->middleware(TunnelMiddleware::class); $this->app->routeMiddleware(['rpc.security' => Security::class]); $this->app->router->group([