Skip to content

Commit

Permalink
Support Nezha over Argo with SSL/TLS
Browse files Browse the repository at this point in the history
  • Loading branch information
fscarmen2 committed Apr 18, 2023
1 parent 4d9b2c5 commit c6f8465
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
| UUID || de04add9-5c68-8bab-950c-08cd5320df18 | 可在线生成 https://www.zxgj.cn/g/uuid |
| WSPATH || argo | 勿以 / 开头,各协议路径为 `/WSPATH-协议`,如 `/argo-vless`,`/argo-vmess`,`/argo-trojan`,`/argo-shadowsocks` |
| NEZHA_SERVER || | 哪吒探针服务端的 IP 或域名,与 NEZHA_ARGO 只能同时存在一个 |
| NEZHA_ARGO || | 哪吒探针服务端的 argo 隧道域名,与 NEZHA_SERVER 只能同时存在一个 |
| NEZHA_PORT || | 哪吒探针服务端的端口,如果服务端是 Argo,则不需要填写 |
| NEZHA_KEY || | 哪吒探针客户端专用 Key |
| NEZHA_TLS || | 哪吒探针是否启用 SSL/TLS 加密 ,如不启用不要该变量,如要启用填"1" |
| ARGO_AUTH || | Argo 的 Token 或者 json 值 |
| ARGO_DOMAIN || | Argo 的域名,须与 ARGO_DOMAIN 必需一起填了才能生效 |

Expand Down
35 changes: 5 additions & 30 deletions files/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,7 @@ check_run() {
# 三个变量不全则不安装哪吒客户端
check_variable() {
[ -z "\${NEZHA_KEY}" ] && exit
[[ ( -z "\${NEZHA_SERVER}" || -z "\${NEZHA_PORT}" ) && -z "\${NEZHA_ARGO}" ]] && exit
[[ ( -z "\${NEZHA_SERVER}" || -z "\${NEZHA_PORT}" ) || -z "\${NEZHA_KEY}" ]] && exit
}
# 下载最新版本 Nezha Agent
Expand All @@ -318,28 +317,9 @@ generate_pm2_file() {
ARGO_ARGS="tunnel --edge-ip-version auto --no-autoupdate --logfile argo.log --loglevel info --url http://localhost:8080"
fi

if [[ -n "${NEZHA_PORT}" && -n "${NEZHA_KEY}" && -n "${NEZHA_SERVER}" && -z "${NEZHA_ARGO}" ]]; then
cat > ecosystem.config.js << EOF
module.exports = {
"apps":[
{
"name":"web",
"script":"/app/web.js run"
},
{
"name":"argo",
"script":"cloudflared",
"args":"${ARGO_ARGS}"
},
{
"name":"nezha",
"script":"/app/nezha-agent",
"args":"-s ${NEZHA_SERVER}:${NEZHA_PORT} -p ${NEZHA_KEY}"
}
]
}
EOF
elif [[ -n "${NEZHA_KEY}" && -z "${NEZHA_SERVER}" && -n "${NEZHA_ARGO}" ]]; then
TLS=${NEZHA_TLS:+'--tls'}

if [[ -n "${NEZHA_SERVER}" && -n "${NEZHA_PORT}" && -n "${NEZHA_KEY}" ]]; then
cat > ecosystem.config.js << EOF
module.exports = {
"apps":[
Expand All @@ -352,15 +332,10 @@ module.exports = {
"script":"cloudflared",
"args":"${ARGO_ARGS}"
},
{
"name":"nezha server",
"script":"cloudflared",
"args":"access tcp --hostname ${NEZHA_ARGO} --listener localhost:55556"
},
{
"name":"nezha",
"script":"/app/nezha-agent",
"args":"-s localhost:55556 -p ${NEZHA_KEY}"
"args":"-s ${NEZHA_SERVER}:${NEZHA_PORT} -p ${NEZHA_KEY} ${TLS}"
}
]
}
Expand Down

0 comments on commit c6f8465

Please sign in to comment.