parent
d8e7f8d5d7
commit
635d3f23e6
|
|
@ -68,7 +68,9 @@ function amh_module_admin()
|
||||||
echo "stop something";
|
echo "stop something";
|
||||||
;;
|
;;
|
||||||
add)
|
add)
|
||||||
echo "add something";
|
proxy_pass=$3;
|
||||||
|
php ${module_dir}cli.php --action='add' --server_name=${domain} --proxy_pass=${proxy_pass};
|
||||||
|
amh nginx reload;
|
||||||
;;
|
;;
|
||||||
edit)
|
edit)
|
||||||
echo "edit something";
|
echo "edit something";
|
||||||
|
|
|
||||||
48
cli.php
48
cli.php
|
|
@ -46,7 +46,7 @@
|
||||||
echo amproxy_list($param['proxy_status']);
|
echo amproxy_list($param['proxy_status']);
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
//echo amproxy_add($param['server_name'], $param['proxy_pass']);
|
echo amproxy_add($param['server_name'], $param['proxy_pass']);
|
||||||
break;
|
break;
|
||||||
case 'edit':
|
case 'edit':
|
||||||
//echo amproxy_edit($param['server_name'], $param['field_name'], $param['value']);
|
//echo amproxy_edit($param['server_name'], $param['field_name'], $param['value']);
|
||||||
|
|
@ -83,3 +83,49 @@
|
||||||
}
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新建反向代理
|
||||||
|
* @param $server_name
|
||||||
|
* @param string $proxy_pass
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function amproxy_add($server_name, $proxy_pass = '')
|
||||||
|
{
|
||||||
|
if (empty($server_name)) {
|
||||||
|
return "[ERROR] The server_name is empty.\n";//不能为空
|
||||||
|
}
|
||||||
|
|
||||||
|
$res = '';
|
||||||
|
global $medoo;
|
||||||
|
$table = 'module_hyproxy';
|
||||||
|
$columns = '*';
|
||||||
|
$where = array('server_name'=>trim($server_name));
|
||||||
|
$proxy = $medoo->get($table, $columns, $where);
|
||||||
|
|
||||||
|
if ($proxy) {
|
||||||
|
return "[Error] $server_name AMProxy is exist!\n";//已存在
|
||||||
|
} else {
|
||||||
|
empty($proxy_pass) && $proxy_pass = 'http://'.$server_name;
|
||||||
|
if (!preg_match('/^http(s)?:\\/\\/.+/', $proxy_pass)) {
|
||||||
|
$proxy_pass = 'http://'.$proxy_pass;
|
||||||
|
}
|
||||||
|
$data = array(
|
||||||
|
'server_name' => $server_name,
|
||||||
|
'`index`' => 'index.php index.html index.htm',//index是保留字段
|
||||||
|
'header_host' => '$host',
|
||||||
|
'proxy_pass' => $proxy_pass,
|
||||||
|
'proxy_cache' => 1,
|
||||||
|
'status' => 'start',
|
||||||
|
'time' => time()
|
||||||
|
);
|
||||||
|
$mysqlres = $medoo->insert($table, $data);
|
||||||
|
if ($mysqlres) {
|
||||||
|
$res = "[OK] successfully create $server_name AMProxy.\n";
|
||||||
|
shell_exec("php "._HYPROXY."hyproxy-cli.php --action='make' --server_name=$server_name");
|
||||||
|
} else {
|
||||||
|
$res = "[ERROR] error create $server_name AMProxy.\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue