From 47197484cad8ade210987e484ca1f9120c81d600 Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 17 Jun 2021 15:23:34 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE=E6=94=B9v?= =?UTF-8?q?2ray=20gRPC=20nginx=E9=85=8D=E7=BD=AE=E3=80=81=E4=BC=98?= =?UTF-8?q?=E5=8C=96tls=E5=AE=89=E8=A3=85=E5=88=A4=E6=96=AD=E3=80=81?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=8D=E4=BD=BF=E7=94=A8gRPC=E7=9A=84h2?= =?UTF-8?q?=E5=9B=9E=E8=90=BD=E4=BB=A5=E5=8A=A0=E5=BF=AB=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E7=9A=84=E8=AE=BF=E9=97=AE=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 66 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 27 deletions(-) diff --git a/install.sh b/install.sh index b607fb0..bf3a12f 100644 --- a/install.sh +++ b/install.sh @@ -616,20 +616,20 @@ initTLSNginxConfig() { updateRedirectNginxConf() { cat </etc/nginx/conf.d/alone.conf - server { - listen 80; - listen [::]:80; - server_name ${domain}; - # shellcheck disable=SC2154 - return 301 https://${domain}$request_uri; - } - server { - listen 127.0.0.1:31300; - server_name _; - return 403; - } +server { + listen 80; + listen [::]:80; + server_name ${domain}; + # shellcheck disable=SC2154 + return 301 https://${domain}$request_uri; +} +server { + listen 127.0.0.1:31300; + server_name _; + return 403; +} EOF - if [[ "${selectCoreType}" == "1" ]] && [[ -n $(echo ${selectCustomInstallType} | grep 5) || -z ${selectCustomInstallType} ]]; then + if echo "${selectCustomInstallType}" |grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then cat <>/etc/nginx/conf.d/alone.conf server { listen 127.0.0.1:31302 http2; @@ -639,6 +639,17 @@ server { grpc_pass grpc://127.0.0.1:31301; } } +EOF + elif ! echo "${selectCustomInstallType}" |grep -q 4; then + + cat <>/etc/nginx/conf.d/alone.conf +server { + listen 127.0.0.1:31302 http2; + server_name ${domain}; + root /usr/share/nginx/html; + location / { + } +} EOF fi @@ -694,7 +705,7 @@ installTLS() { echoContent skyBlue "\n进度 $1/${totalProgress} : 申请TLS证书\n" local tlsDomain=${domain} # 安装tls - if [[ -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" && -f "/etc/v2ray-agent/tls/${tlsDomain}.key" ]] || [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then + if [[ -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" && -f "/etc/v2ray-agent/tls/${tlsDomain}.key" && -n $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]] || [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then # 存在证书 echoContent green " ---> 检测到证书" checkTLStatus "${tlsDomain}" @@ -705,7 +716,7 @@ installTLS() { else echoContent green " ---> 证书有效" - if ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.crt" || ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.key"; then + if ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.crt" || ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.key" || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null else echoContent yellow " ---> 如未过期请选择[n]\n" @@ -724,11 +735,12 @@ installTLS() { sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 >> /etc/v2ray-agent/tls/acme.log fi - sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null - if [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then - echoContent red " ---> TLS安装失败,请检查acme日志" - exit 0 - elif [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.key") ]]; then + if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then + sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null + fi + + if [[ ! -f "/etc/v2ray-agent/tls/${tlsDomain}.crt" || ! -f "/etc/v2ray-agent/tls/${tlsDomain}.key" ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.key") || -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then + tail -n 10 /etc/v2ray-agent/tls/acme.log echoContent red " ---> TLS安装失败,请检查acme日志" exit 0 fi @@ -1574,7 +1586,7 @@ EOF EOF # VLESS_TCP_TLS/XTLS # 回落nginx - local fallbacksList='{"dest":31300,"xver":0}' + local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then # 回落trojan-go @@ -1691,7 +1703,7 @@ EOF fi # VLESS gRPC if echo "${selectCustomInstallType}" | grep -q 5 || [[ "$1" == "all" ]]; then - fallbacksList=${fallbacksList}',{"alpn":"h2","dest":31301,"xver":0}' +# fallbacksList=${fallbacksList}',{"alpn":"h2","dest":31301,"xver":0}' cat </etc/v2ray-agent/v2ray/conf/06_VLESS_gRPC_inbounds.json { "inbounds":[ @@ -1809,7 +1821,7 @@ EOF if echo "${selectCustomInstallType}" | grep -q 5 || [[ "$1" == "all" ]];then echo >/dev/null - elif [[ -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]];then + elif [[ -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]] && echo "${selectCustomInstallType}" | grep -q 4;then # "h2", sed -i '/\"h2\",/d' $(grep "\"h2\"," -rl /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json) fi @@ -1925,7 +1937,7 @@ EOF EOF # VLESS_TCP_TLS/XTLS # 回落nginx - local fallbacksList='{"dest":31300,"xver":0}' + local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}' if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then # 回落trojan-go @@ -2042,7 +2054,7 @@ EOF fi if echo "${selectCustomInstallType}" | grep -q 5 || [[ "$1" == "all" ]]; then - fallbacksList=${fallbacksList}',{"alpn":"h2","dest":31302,"xver":0}' +# fallbacksList=${fallbacksList}',{"alpn":"h2","dest":31302,"xver":0}' cat </etc/v2ray-agent/xray/conf/06_VLESS_gRPC_inbounds.json { "inbounds":[ @@ -2120,7 +2132,7 @@ EOF EOF if echo "${selectCustomInstallType}" | grep -q 5 || [[ "$1" == "all" ]];then echo >/dev/null - elif [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" ]];then + elif [[ -f "/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json" ]] && echo "${selectCustomInstallType}" | grep -q 4;then # "h2", sed -i '/\"h2\",/d' $(grep "\"h2\"," -rl /etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json) fi @@ -3897,7 +3909,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v2.5.2" + echoContent green "当前版本:v2.5.3" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus