In Yii 2, the RPC service is implemented based on HProse, and the error is reported: passthru() has been disabled for security reasons
1. In the local environment, post in postman , http://api.aims-api.localhost/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 , the response is successful
{
"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
"title":"Title - 20180809 - 1",
"Source": "XContent",
"media_path":"http://www.media_path.com",
"type":"mc_vca",
"callback_url":"http://www.callback_url.com",
"dlurl":"http://www.dlurl.com"
}
{
"code": 10000,
"message": "Submit task was successful",
"data": {
"id": 14,
"group_id": "015ce30b116ce86058fa6ab4fea4ac63",
"task_uuid": "B914E6E49B9F11E8872454EE75D2EBC1",
"title": "Title - 20180809 - 1",
"source": "xcontent",
"media_path": "http://www.media_path.com",
"dlurl": "http://www.dlurl.com",
"callback_url": "http://www.callback_url.com",
"ai_task_type": "mc_vca",
"ai_task_status": 0,
"pri": 2,
"pri_updated_at": 0,
"status": 1,
"created_at": 1533797093,
"updated_at": 1533797093
}
}
2. In development environment, post in postman , http://wjdev2.chinamcloud.com:8659/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 , the response failed, as shown in Figure 2
{
"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
"title":"Title - 20180809 - 1",
"Source": "XContent",
"media_path":"http://www.media_path.com",
"type":"mc_vca",
"callback_url":"http://www.callback_url.com",
"dlurl":"http://www.dlurl.com"
}
{
{
"name": "exception",
"message": "passthru() has been disabled for security reasons",
"code": 0,
"type": "exception",
"file": "/sobey/www/aims-api/vendor/hprose/hprose/src/hprose/client.php",
"line": 383,
"stack-trace":[
"#0 /sobey/www/aims-api/vendor/hprose/hprose/src/hprose/client.php(477): hprose\\client->decode(es49\"passthru()..., array, Object(stdClass)",
"#1 /sobey/www/aims-api/vendor/hprose/hprose/src/hprose/client.php(489): hprose\\client->SyncInvokeHandler(task_create, array, Object(stdClass)",
"#2 /sobey/www/aims-api/vendor/hprose/hprose/src/hprose/client.php(103): hprose\\client->InvokeHandler(task_create, array, Object(stdClass)",
"#3 /sobey/www/aims-api/vendor/hprose/hprose/src/hprose/client.php(608): hprose\\client->hprose\\{closure}(task_create, array, Object(stdClass)",
"#4 /sobey/www/aims-api/vendor/hprose/hprose/src/hprose/proxy.php(91): hprose\\client->invoke(task_create, array)",
"#5 /sobey/www/aims-api/common/logics/rpc/task.php(106): hprose\\proxy->_call(task_create, array)",
"#6 /sobey/www/aims-api/common/services/taskservice.php(30): Common\\logics\\rpc\\task->create(array,0.0,en)",
"#7 /sobey/www/aims-api/api/rests/task/createaction.php(65): Common\\Services\\TaskService->create(object(api\\modules\v1\\models\rpc\\task))",
"#8 [internal function]#atfp_close_translate_span#: api\\rests\task\createaction->run()",
"#9 /sobey/www/aims-api/vendor/yiisoft/yii2/base/action.php(94): call_user_func_array(array, array),
"#10 /sobey/www/aims-api/vendor/yiisoft/yii2/base/controller.php(157): yii\\base\\action->runWithParams(array)",
"#11 /sobey/www/aims-api/vendor/yiisoft/yii2/base/module.php(528): yii\\base\\controller->RunAction(Create, array)",
"#12 /sobey/www/aims-api/vendor/yiisoft/yii2/web/application.php(103): yii\\base\\module->RunAction(v1/task/create, array)",
"#13 /sobey/www/aims-api/vendor/yiisoft/yii2/base/application.php(386): yii\\web\\application->handleRequest(object(yii\\web\\request))",
"#14 /sobey/www/aims-api/api/web/index.php(17): yii\\base\application->run()",
"#15 {main}"
]
}
3. Edit the Dockerfile of the interface (RPC client), and delete the passthru in disable_functions
from registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4 Maintainer wangqiang@chinamcloud.com run sed -is/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g/usr/local/php/etc/php.ini && \ sed-is/allow_url_fopen = off/allow_url_fopen = on/g/usr/local/php/etc/php.ini && \ sed-is/disable_functions = exec, system, passthru, shell_exec, escapeshellarg, escapeshel lcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g/usr/local/php/etc/php.ini copy code /sobey/www/aims-api copy code/build/c_files/ / run chown -r nginx:nginx /sobey/www/ && \ rm -rf /etc/nginx/conf.d/status.conf && \ chmod +x /usr/local/bin/composer && \ cd /sobey/www/aims-api && \ composer install
4. Edit the Dockerfile of the RPC server and delete the passthru in the disable_functions
from registry-vpc.cn-beijing.aliyuncs.com/cmc/centos-nginx112-php71:0.2.4 Maintainer wangqiang@chinamcloud.com run sed -is/open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv/;open_basedir = .\/:\/sobey:\/tmp:\/data:\/webtv:\/usr\/local\/php/g/usr/local/php/etc/php.ini && \ sed-is/allow_url_fopen = off/allow_url_fopen = on/g/usr/local/php/etc/php.ini && \ sed-is/disable_functions = exec, system, passthru, shell_exec, escapeshellarg, escapeshel lcmd,proc_close,proc_open,dl,popen,show/disable_functions = system,shell_exec,escapeshellarg,escapeshellcmd,dl,popen,show/g/usr/local/php/etc/php.ini copy code /sobey/www/aims-rpc copy code/build/c_files/ / run chown -r nginx:nginx /sobey/www/ && \ rm -rf /etc/nginx/conf.d/status.conf && \ chmod +x /usr/local/bin/composer && \ cd /sobey/www/aims-rpc && \ composer install
5. In the development environment, post in postman , http://wjdev2.chinamcloud.com:8659/v1/tasks?group_id=015ce30b116ce86058fa6ab4fea4ac63 , respond to success
{
"group_id":"015ce30b116ce86058fa6ab4fea4ac63",
"title":"Title - 20180811 - 6",
"Source": "XContent",
"media_path":"http://www.media_path.com",
"type":"mc_vca",
"callback_url":"http://www.callback_url.com",
"dlurl":"http://www.dlurl.com"
}
{
"code": 10000,
"message": "Submit task was successful",
"data": {
"id": 5,
"group_id": "015ce30b116ce86058fa6ab4fea4ac63",
"task_uuid": "D9C9092A9D4711E8AD5E54EE75D2EDC1",
"title": "Title - 20180811 - 5",
"source": "xcontent",
"media_path": "http://www.media_path.com",
"dlurl": "http://www.dlurl.com",
"callback_url": "http://www.callback_url.com",
"ai_task_type": "mc_vca",
"ai_task_status": 0,
"pri": 2,
"pri_updated_at": 0,
"status": 1,
"created_at": 1533980458,
"updated_at": 1533980458
}
}
