在Yii2中,如何允许使用适当的(指定的)IP地址访问模块


How to allow access to the module with the appropriate(specify) IP addresses, in Yii2?

如何允许访问模块与适当的(指定)IP地址,在Yii2?

I try, but give error:

Unknown Property – yii'base'UnknownPropertyException
Setting unknown property: app'modules'getsp'getsp::allowedIPs

web.php

//....
'modules' => [
    'getsp' => [
        'class' => 'app'modules'getsp'getsp',
        'allowedIPs' => ['127.0.0.1', '::1'],
    ],                        
], 
 //...

尝试这个解决方案可能会解决您的问题。

Main-local.php

if (!YII_ENV_TEST) {
// configuration adjustments for 'dev' environment
$config['bootstrap'][] = 'debug';
$config['modules']['debug'] = 'yii'debug'Module';
$config['bootstrap'][] = 'getsp';
$config['modules']['getsp'] = 'yii'getsp'Module';
}

Main.php

'modules' => [
    'getsp' => [
        'class' => 'yii'getsp'Module',
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.1.*', 'XXX.XXX.XXX.XXX'] // The server machine ip is ex:-(192.168.1.102). or your PC PC ip address ex:-(192.168.1.101) adjust this to your needs
    ],
],