notamedia/yii2-sentry

Can't stop: Warning: Access to debugger is denied due to IP address restriction. The requesting IP address is

newscloud opened this issue · 3 comments

Hi,

On one of my sites Sentry plugin works great, but on this other site I keep getting this warning report: https://screencast.com/t/pW2jzG689

Frontend/web/index.php
`<?php
defined('YII_DEBUG') or define('YII_DEBUG', false);
defined('YII_ENV') or define('YII_ENV', 'prod');

require(DIR . '/../../vendor/autoload.php');
require(DIR . '/../../vendor/yiisoft/yii2/Yii.php');
require(DIR . '/../../common/config/bootstrap.php');
require(DIR . '/../config/bootstrap.php');

$config = yii\helpers\ArrayHelper::merge(
require(DIR . '/../../common/config/main.php'),
require(DIR . '/../../common/config/main-local.php'),
require(DIR . '/../config/main.php'),
require(DIR . '/../config/main-local.php')
);

$application = new yii\web\Application($config);
$application->run();
`

main.php, not sure how to configure this so sentry is live on production but debug is not

return [ 'id' => 'app-frontend', 'basePath' => dirname(__DIR__), 'bootstrap' => ['chiliec\vote\components\VoteBootstrap','log','\common\components\SiteHelper'], // 'debug' 'components' => [ 'assetManager' => [ 'appendTimestamp' => true, ], ], 'modules' => [ 'debug' => [ 'class' => 'yii\debug\Module', ],

'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'notamedia\sentry\SentryTarget', 'dsn' => 'http://'.$config['sentry_key_public']. ':'.$config['sentry_key_private']. '@sentry.io/'.$config['sentry_id'], 'levels' => ['error', 'warning'], 'context' => true, // Write the context information. The default is ], ], ],

Hi, you have invalid configuration. The correct way would be:

return [
	'id' => 'app-frontend', 
	'basePath' => dirname(__DIR__), 
	'bootstrap' => [
		'chiliec\vote\components\VoteBootstrap', 
		'log', 
		'\common\components\SiteHelper'
	],
	'modules' => [
		'debug' => [
			'class' => 'yii\debug\Module'
		],
	],
	'components' => [
		'assetManager' => ['appendTimestamp' => true], 
		'log' => [
			'traceLevel' => YII_DEBUG ? 3 : 0, 
			'targets' => [
				[
					'class' => 'notamedia\sentry\SentryTarget', 
					'dsn' => 'http://' . $config['sentry_key_public'] . ':' . $config['sentry_key_private'] . '@sentry.io/' . $config['sentry_id'], 
					'levels' => ['error', 'warning'], 
					'context' => true, // Write the context information. The default is 
				], 
			], 
		]
	]
];

http://www.yiiframework.com/doc-2.0/guide-runtime-logging.html#log-targets

Thanks, I'll try it as soon as I can.

Please let me know if you saw this - because the issue is closed. Should I create a new issue?

Hi, I went back and looked at this ... the example I gave you had an extra ] closing the components array. I am still getting this error all the time when search engines / scanners hit api.meetingplanner.io

https://screencast.com/t/oxpdAwhpssJn

return [ 'id' => 'app-api', 'basePath' => dirname(__DIR__), 'controllerNamespace' => 'api\controllers', 'bootstrap' => ['log'], 'components' => [ 'log' => [ 'traceLevel' => YII_DEBUG ? 3 : 0, 'targets' => [ [ 'class' => 'notamedia\sentry\SentryTarget', 'dsn' => 'http://'.$config['sentry_key_public'].':'.$config['sentry_key_private'].'@sentry.io/'.$config['sentry_id'], 'levels' => ['error', 'warning'], 'context' => true, // Write the context information. The default is true. ], ], ], 'errorHandler' => [ 'errorAction' => 'service/error', ], ...