1.在服务器上配置好代理
取得ip以及端口
2.青龙可以在config中配置代理或者是环境变量
我个人喜欢在环境变量中添加

在容器bridge模式下,用172.17.0.1作为主机(默认情况)
host模式下使用127.0.0.1
http_和https_proxy 这俩环境变量 python会自动读取并使用

nodejs则使用global-agent进行代理 如图配置环境变量
nodejs需要安装global-agent依赖
2.3全局代理
青龙面板是使用node命令来执行js脚本的,因此我们可以设置node运行-r参数来达到全局代理的目的:
node -r 'global-agent/bootstrap' your-script.js
目前个人使用的面板版本是2.10.13,该版本面板并不提供设置运行参数的功能(高版本有),只能通过修改源码加入-r参数了。
进入青龙面板容器的目录后,打开ql/shell/task.sh,部分源码如下:
-
#!/usr/bin/env bash -
## 导入通用变量与函数 -
dir_shell=/ql/shell -
. $dir_shell/share.sh -
. $dir_shell/api.sh -
## 选择python3还是node -
define_program() { -
local first_param=$1 -
if [[ $first_param == *.js ]]; then -
which_program="node" -
elif [[ $first_param == *.py ]]; then -
which_program="python3" -
elif [[ $first_param == *.sh ]]; then -
which_program="bash" -
elif [[ $first_param == *.ts ]]; then -
which_program="ts-node-transpile-only" -
else -
which_program="" -
fi -
}
修改node的运行命令,即加入-r参数,保存即可:
-
#!/usr/bin/env bash -
## 导入通用变量与函数 -
dir_shell=/ql/shell -
. $dir_shell/share.sh -
. $dir_shell/api.sh -
## 选择python3还是node -
define_program() { -
local first_param=$1 -
if [[ $first_param == *.js ]]; then -
which_program="node -r global-agent/bootstrap" -
elif [[ $first_param == *.py ]]; then -
which_program="python3" -
elif [[ $first_param == *.sh ]]; then -
which_program="bash" -
elif [[ $first_param == *.ts ]]; then -
which_program="ts-node-transpile-only" -
else -
which_program="" -
fi -
}
注意,大多数代理是'数据中心'代理,如果你是为了解除IP类型限制,请参照前面教程进行测试以选择合适的代理。


















