mirror of
https://github.com/samuelhbne/server-xray.git
synced 2025-12-18 21:04:38 +03:00
Squashed commit of the following:
commit8c90a783b6Author: Samuel Huang <samuelh2006@gmail.com> Date: Fri Oct 4 20:37:19 2024 +1000 Trivy compliant commit05857d2008Author: Samuel Huang <samuelh2006@gmail.com> Date: Thu Oct 3 21:44:08 2024 +1000 Add workflow_dispatch to Codacy commit4d3a971d17Author: Samuel Huang <samuelh2006@gmail.com> Date: Thu Oct 3 21:36:40 2024 +1000 Trivy compliant commita9c25bbf1fAuthor: Samuel Huang <samuelh2006@gmail.com> Date: Thu Oct 3 20:56:44 2024 +1000 Update trivy scanner commit368a9c36e0Author: Samuel Huang <samuelh2006@gmail.com> Date: Tue Oct 1 08:20:43 2024 +1000 Codacy compliant
This commit is contained in:
1
.github/workflows/codacy.yml
vendored
1
.github/workflows/codacy.yml
vendored
@@ -14,6 +14,7 @@
|
|||||||
name: Codacy Security Scan
|
name: Codacy Security Scan
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches: [ "master", "dev" ]
|
branches: [ "master", "dev" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
|
|||||||
12
.github/workflows/trivy-scan.yml
vendored
12
.github/workflows/trivy-scan.yml
vendored
@@ -1,6 +1,7 @@
|
|||||||
name: Trivy-scanning
|
name: Trivy-scanning
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
@@ -12,21 +13,20 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
-
|
-
|
||||||
name: Checkout
|
name: Checkout
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
ref: ${{ github.ref }}
|
ref: ${{ github.ref }}
|
||||||
-
|
-
|
||||||
name: Run Trivy fs vulnerability scanner
|
name: Run Trivy fs vulnerability scanner in fs mode
|
||||||
uses: anandg112/trivy-action@feat/add-skip-dirs-option
|
uses: aquasecurity/trivy-action@0.20.0
|
||||||
with:
|
with:
|
||||||
scan-type: 'fs'
|
scan-type: 'fs'
|
||||||
ignore-unfixed: true
|
ignore-unfixed: true
|
||||||
format: 'template'
|
format: 'sarif'
|
||||||
template: '@/contrib/sarif.tpl'
|
|
||||||
output: 'trivy-results.sarif'
|
output: 'trivy-results.sarif'
|
||||||
#severity: 'CRITICAL'
|
#severity: 'CRITICAL'
|
||||||
-
|
-
|
||||||
name: Upload Trivy scan results to GitHub Security tab
|
name: Upload Trivy scan results to GitHub Security tab
|
||||||
uses: github/codeql-action/upload-sarif@v2
|
uses: github/codeql-action/upload-sarif@v3
|
||||||
with:
|
with:
|
||||||
sarif_file: 'trivy-results.sarif'
|
sarif_file: 'trivy-results.sarif'
|
||||||
|
|||||||
48
Dockerfile
48
Dockerfile
@@ -9,8 +9,8 @@ RUN git clone https://github.com/XTLS/Xray-core.git . && \
|
|||||||
git checkout ${XRAYVER} && \
|
git checkout ${XRAYVER} && \
|
||||||
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
|
go build -o xray -trimpath -ldflags "-s -w -buildid=" ./main
|
||||||
|
|
||||||
RUN cd /tmp; curl -sSLO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
RUN curl -sSLO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geoip.dat
|
||||||
RUN cd /tmp; curl -sSLO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
RUN curl -sSLO https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/geosite.dat
|
||||||
|
|
||||||
|
|
||||||
FROM nginx:stable-alpine3.20
|
FROM nginx:stable-alpine3.20
|
||||||
@@ -18,12 +18,13 @@ FROM nginx:stable-alpine3.20
|
|||||||
ARG ACMEVER='2.9.0'
|
ARG ACMEVER='2.9.0'
|
||||||
|
|
||||||
COPY --from=builder /go/src/XTLS/Xray-core/xray /usr/local/bin/
|
COPY --from=builder /go/src/XTLS/Xray-core/xray /usr/local/bin/
|
||||||
COPY --from=builder /tmp/geosite.dat /usr/local/bin/
|
COPY --from=builder /go/src/XTLS/Xray-core/geoip.dat /usr/local/bin/
|
||||||
COPY --from=builder /tmp/geoip.dat /usr/local/bin/
|
COPY --from=builder /go/src/XTLS/Xray-core/geosite.dat /usr/local/bin/
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
RUN apk add --no-cache bash openssl curl socat jq moreutils libcap-setcap
|
RUN apk add --no-cache bash openssl curl socat jq moreutils libcap-setcap
|
||||||
RUN cd /root; curl -sSL "https://github.com/acmesh-official/acme.sh/archive/refs/tags/${ACMEVER}.tar.gz"|tar zxvf -
|
RUN curl -sSL "https://github.com/acmesh-official/acme.sh/archive/refs/tags/${ACMEVER}.tar.gz"|tar zxvf -
|
||||||
RUN cd /root; ln -s acme.sh-${ACMEVER} acme.sh; mkdir .acme.sh
|
RUN ln -s acme.sh-${ACMEVER} acme.sh; mkdir .acme.sh
|
||||||
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/nginx
|
RUN setcap CAP_NET_BIND_SERVICE=+eip /usr/sbin/nginx
|
||||||
|
|
||||||
COPY nginx-site.tpl /etc/nginx/conf.d/
|
COPY nginx-site.tpl /etc/nginx/conf.d/
|
||||||
@@ -31,33 +32,32 @@ COPY nginx-stream.tpl /etc/nginx/conf.d/
|
|||||||
COPY nginx-proxy.tpl /etc/nginx/conf.d/
|
COPY nginx-proxy.tpl /etc/nginx/conf.d/
|
||||||
COPY nginx-grpc.tpl /etc/nginx/conf.d/
|
COPY nginx-grpc.tpl /etc/nginx/conf.d/
|
||||||
COPY nginx-ws.tpl /etc/nginx/conf.d/
|
COPY nginx-ws.tpl /etc/nginx/conf.d/
|
||||||
|
|
||||||
COPY proxy-log-fmt.tpl /etc/nginx/conf.d/000-proxy-log-fmt.conf
|
COPY proxy-log-fmt.tpl /etc/nginx/conf.d/000-proxy-log-fmt.conf
|
||||||
|
|
||||||
ADD server-lgp.sh /server-lgp.sh
|
COPY server-lgp.sh /server-lgp.sh
|
||||||
ADD server-lgr.sh /server-lgr.sh
|
COPY server-lgr.sh /server-lgr.sh
|
||||||
ADD server-lgt.sh /server-lgt.sh
|
COPY server-lgt.sh /server-lgt.sh
|
||||||
|
|
||||||
ADD server-lsp.sh /server-lsp.sh
|
COPY server-lsp.sh /server-lsp.sh
|
||||||
ADD server-lst.sh /server-lst.sh
|
COPY server-lst.sh /server-lst.sh
|
||||||
|
|
||||||
ADD server-ltr.sh /server-ltr.sh
|
COPY server-ltr.sh /server-ltr.sh
|
||||||
ADD server-ltt.sh /server-ltt.sh
|
COPY server-ltt.sh /server-ltt.sh
|
||||||
|
|
||||||
ADD server-lwp.sh /server-lwp.sh
|
COPY server-lwp.sh /server-lwp.sh
|
||||||
ADD server-lwt.sh /server-lwt.sh
|
COPY server-lwt.sh /server-lwt.sh
|
||||||
|
|
||||||
ADD server-mtt.sh /server-mtt.sh
|
COPY server-mtt.sh /server-mtt.sh
|
||||||
ADD server-mwp.sh /server-mwp.sh
|
COPY server-mwp.sh /server-mwp.sh
|
||||||
ADD server-mwt.sh /server-mwt.sh
|
COPY server-mwt.sh /server-mwt.sh
|
||||||
|
|
||||||
ADD server-twp.sh /server-twp.sh
|
COPY server-twp.sh /server-twp.sh
|
||||||
ADD server-ttt.sh /server-ttt.sh
|
COPY server-ttt.sh /server-ttt.sh
|
||||||
ADD server-twt.sh /server-twt.sh
|
COPY server-twt.sh /server-twt.sh
|
||||||
|
|
||||||
ADD server-nginx.sh /server-nginx.sh
|
COPY server-nginx.sh /server-nginx.sh
|
||||||
|
|
||||||
ADD run.sh /run.sh
|
COPY run.sh /run.sh
|
||||||
|
|
||||||
RUN chmod 755 /*.sh
|
RUN chmod 755 /*.sh
|
||||||
|
|
||||||
|
|||||||
6
run.sh
6
run.sh
@@ -78,13 +78,13 @@ while true ; do
|
|||||||
;;
|
;;
|
||||||
--lgp|--lgr|--lgt|--lsp|--lst|--ltr|--ltt|--lwp|--lwt|--mtt|--mwp|--mwt|--ttt|--twp|--twt)
|
--lgp|--lgr|--lgt|--lsp|--lst|--ltr|--ltt|--lwp|--lwt|--mtt|--mwp|--mwt|--ttt|--twp|--twt)
|
||||||
# Alias options
|
# Alias options
|
||||||
SVC=$(echo $1|tr -d '\-\-')
|
SVC=$(echo "$1"|tr -d "\-\-")
|
||||||
SVCMD+=("${DIR}/server-${SVC}.sh $2")
|
SVCMD+=("${DIR}/server-${SVC}.sh $2")
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
--ltrx|--lttx)
|
--ltrx|--lttx)
|
||||||
# Alias options
|
# Alias options
|
||||||
SVC=$(echo $1|tr -d '\-\-'|tr -d x)
|
SVC=$(echo "$1"|tr -d "\-\-"|tr -d "x")
|
||||||
SVCMD+=("${DIR}/server-${SVC}.sh $2,xtls")
|
SVCMD+=("${DIR}/server-${SVC}.sh $2,xtls")
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
@@ -156,7 +156,7 @@ if [ "${#CERTDOMAIN[@]}" -gt 0 ]; then
|
|||||||
do
|
do
|
||||||
echo "Requesting TLS cert for ${DOMAIN} ..."
|
echo "Requesting TLS cert for ${DOMAIN} ..."
|
||||||
echo "/root/acme.sh/acme.sh --cert-home ${CERTHOME} --issue --standalone -d ${DOMAIN} --debug"
|
echo "/root/acme.sh/acme.sh --cert-home ${CERTHOME} --issue --standalone -d ${DOMAIN} --debug"
|
||||||
/root/acme.sh/acme.sh --cert-home "${CERTHOME}" --issue --standalone -d ${DOMAIN} --debug
|
/root/acme.sh/acme.sh --cert-home "${CERTHOME}" --issue --standalone -d "${DOMAIN}" --debug
|
||||||
((TRY++))
|
((TRY++))
|
||||||
if [ "${TRY}" -ge 3 ]; then
|
if [ "${TRY}" -ge 3 ]; then
|
||||||
echo "Requesting TLS cert for ${DOMAIN} failed. Check log please."
|
echo "Requesting TLS cert for ${DOMAIN} failed. Check log please."
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettin
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ inbound=$(echo $inbound| jq -c --argjson JshortIds "${JshortIds}" '.streamSettin
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then
|
if [ -z "${fport}" ]; then
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then
|
if [ -z "${fport}" ]; then
|
||||||
|
|||||||
@@ -114,18 +114,18 @@ if [ -n "${STSVR}" ]; then
|
|||||||
done
|
done
|
||||||
|
|
||||||
# Adding map.conf down to #XMAP_TAG tag
|
# Adding map.conf down to #XMAP_TAG tag
|
||||||
sed -i '/#XMAP_TAG/r /tmp/stmap.conf' $NGCONF
|
sed -i '/#XMAP_TAG/r /tmp/stmap.conf' "$NGCONF"
|
||||||
# Adding ups.conf down to #XUPSTREAM_TAG tag
|
# Adding ups.conf down to #XUPSTREAM_TAG tag
|
||||||
sed -i '/#XUPSTREAM_TAG/r /tmp/stups.conf' $NGCONF
|
sed -i '/#XUPSTREAM_TAG/r /tmp/stups.conf' "$NGCONF"
|
||||||
sed -i "s/STPORT/${STPORT}/g" $NGCONF
|
sed -i "s/STPORT/${STPORT}/g" "$NGCONF"
|
||||||
# Adding "proxy_protocol=on" down to #STPROXY_PASS_TAG tag
|
# Adding "proxy_protocol=on" down to #STPROXY_PASS_TAG tag
|
||||||
if [ -n "${STPROXY_PASS}" ]; then
|
if [ -n "${STPROXY_PASS}" ]; then
|
||||||
echo " proxy_protocol on;" >/tmp/stproxy.conf
|
echo " proxy_protocol on;" >/tmp/stproxy.conf
|
||||||
sed -i '/#STPROXY_PASS_TAG/r /tmp/stproxy.conf' $NGCONF
|
sed -i '/#STPROXY_PASS_TAG/r /tmp/stproxy.conf' "$NGCONF"
|
||||||
fi
|
fi
|
||||||
rm -rf /tmp/stmap.conf; rm -rf /tmp/stups.conf; rm -rf /tmp/stproxy.conf
|
rm -rf /tmp/stmap.conf; rm -rf /tmp/stups.conf; rm -rf /tmp/stproxy.conf
|
||||||
echo "Generated $NGCONF ====>"
|
echo "Generated $NGCONF ====>"
|
||||||
cat $NGCONF
|
cat "$NGCONF"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Generating Nginx site server configurations.
|
# Generating Nginx site server configurations.
|
||||||
@@ -194,7 +194,7 @@ do
|
|||||||
sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${site_domain}.conf"
|
sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${site_domain}.conf"
|
||||||
fi
|
fi
|
||||||
echo "Generated /etc/nginx/conf.d/${site_domain}.conf ====>"
|
echo "Generated /etc/nginx/conf.d/${site_domain}.conf ====>"
|
||||||
cat /etc/nginx/conf.d/${site_domain}.conf
|
cat "/etc/nginx/conf.d/${site_domain}.conf"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -239,19 +239,19 @@ do
|
|||||||
# Add tpl file content down to #LOCATION tag
|
# Add tpl file content down to #LOCATION tag
|
||||||
case "${xnetwork}" in
|
case "${xnetwork}" in
|
||||||
ws|websocket)
|
ws|websocket)
|
||||||
sed -i '/#XLOCATION_TAG/r nginx-ws.tpl' ${xdomain}.conf
|
sed -i '/#XLOCATION_TAG/r nginx-ws.tpl' "${xdomain}.conf"
|
||||||
;;
|
;;
|
||||||
grpc)
|
grpc)
|
||||||
sed -i '/#XLOCATION_TAG/r nginx-grpc.tpl' ${xdomain}.conf
|
sed -i '/#XLOCATION_TAG/r nginx-grpc.tpl' "${xdomain}.conf"
|
||||||
;;
|
;;
|
||||||
splt|proxy)
|
splt|proxy)
|
||||||
sed -i '/#XLOCATION_TAG/r nginx-proxy.tpl' ${xdomain}.conf
|
sed -i '/#XLOCATION_TAG/r nginx-proxy.tpl' "${xdomain}.conf"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
ESC_LOCATION=$(printf '%s\n' "${xlocation}" | sed -e 's/[]\/$*.^[]/\\&/g')
|
ESC_LOCATION=$(printf '%s\n' "${xlocation}" | sed -e 's/[]\/$*.^[]/\\&/g')
|
||||||
sed -i "s/HOST/${xhost}/g" ${xdomain}.conf
|
sed -i "s/HOST/${xhost}/g" "${xdomain}.conf"
|
||||||
sed -i "s/PORT/${xport}/g" ${xdomain}.conf
|
sed -i "s/PORT/${xport}/g" "${xdomain}.conf"
|
||||||
sed -i "s/WEBPATH/${ESC_LOCATION}/g" ${xdomain}.conf
|
sed -i "s/WEBPATH/${ESC_LOCATION}/g" "${xdomain}.conf"
|
||||||
# Applying proxy log format instead of main format when --ng-server proxy_pass was set
|
# Applying proxy log format instead of main format when --ng-server proxy_pass was set
|
||||||
if [ -n "${NGPROTOCOL}" ]; then
|
if [ -n "${NGPROTOCOL}" ]; then
|
||||||
sed -i '/access_log/s/main/proxy/' "${xdomain}.conf"
|
sed -i '/access_log/s/main/proxy/' "${xdomain}.conf"
|
||||||
@@ -259,7 +259,7 @@ do
|
|||||||
sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${xdomain}.conf"
|
sed -i 's/proxy_add_x_forwarded_for/proxy_protocol_addr/g' "${xdomain}.conf"
|
||||||
fi
|
fi
|
||||||
echo "Generated /etc/nginx/conf.d/${xdomain}.conf ====>"
|
echo "Generated /etc/nginx/conf.d/${xdomain}.conf ====>"
|
||||||
cat /etc/nginx/conf.d/${xdomain}.conf
|
cat "/etc/nginx/conf.d/${xdomain}.conf"
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
if [ -z "${fport}" ]; then >&2 echo -e "Incorrect fallback format: $fb\n"; usage; exit 1; fi
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ inbound=$(echo $inbound| jq -c '.streamSettings += {"security":"none"}')
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then
|
if [ -z "${fport}" ]; then
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ inbound=$(echo $inbound| jq -c --arg fullchain "${fullchain}" --arg prvkey "${pr
|
|||||||
# Fallback settings
|
# Fallback settings
|
||||||
for fb in "${fallback[@]}"
|
for fb in "${fallback[@]}"
|
||||||
do
|
do
|
||||||
IFS=':'; fopt=(${fb}); fopt=(${fopt[@]})
|
IFS=':'; fopt=("${fb}"); fopt=("${fopt[@]}")
|
||||||
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
fhost="${fopt[0]}"; fport="${fopt[1]}"; fpath="${fopt[2]}"
|
||||||
unset IFS
|
unset IFS
|
||||||
if [ -z "${fport}" ]; then
|
if [ -z "${fport}" ]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user