Skip to content

Commit

Permalink
支持多端口
Browse files Browse the repository at this point in the history
  • Loading branch information
KtKID committed Apr 8, 2023
1 parent 92159f8 commit d81c9b8
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
22 changes: 16 additions & 6 deletions build_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,29 @@ else

docker build -t docker-nginx-v2ray .

SITE_DOMAIN="domain" #你的域名
SSL_PORT=13431
SITE_DOMAIN="kingkid.fun" #你的域名
SSL_PORT_START=50000 #start-end受限于nginx最大连接数量
SSL_PORT_END=50010
V2RAY_PORT=54321

port_flags=""
for((i=$SSL_PORT_START; i<$SSL_PORT_END; i++))
do
port_flags+="-p $i:$i "
done
echo "ssl port is $port_flags"

docker container run \
-d \
--name nginx-v2ray \
$port_flags \
-p ${V2RAY_PORT}:${V2RAY_PORT} \
-p ${SSL_PORT}:${SSL_PORT} \
-v "/etc/letsencrypt/archive/${SITE_DOMAIN}":/data/cert/${SITE_DOMAIN} \
-e SITE_DOMAIN="${SITE_DOMAIN}" \
-e V2RAY_TOKEN="0000000-0000-0000-000-000000" \
-e V2RAY_TOKEN="981e3a35-ee2c-4b78-874b-ec8acf87edc2" \
-e V2RAY_PORT=${V2RAY_PORT} \
-e SSL_PORT=${SSL_PORT} \
-e V2RAY_WS_PATH=/king \
-e SSL_PORT_START=${SSL_PORT_START} \
-e SSL_PORT_END=${SSL_PORT_END} \
-e V2RAY_WS_PATH=/xxx \
docker-nginx-v2ray
fi
7 changes: 6 additions & 1 deletion conf/nginx/nginx.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Listen on ports 5000-60000 and SSL_PORT-60000 for SSL
${INSERT_HERE}
listen ${SSL_PORT}-60000 ssl default_server;
listen 5000-60000 ssl default_server;

server {
listen ${SSL_PORT} ssl default_server;
listen ${SSL_PORT_START}-${SSL_PORT_END} ssl default_server;
listen [::]:${SSL_PORT} ssl;

server_name ${SITE_DOMAIN};
Expand Down
8 changes: 5 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ echo "SITE DOMAIN : ${SITE_DOMAIN}"
echo "V2RAY TOKEN : ${V2RAY_TOKEN}"
echo "V2RAY WS PATH : ${V2RAY_WS_PATH}"
echo "V2RAY_PORT : ${V2RAY_PORT}"
echo "SSL_PORT : ${SSL_PORT}"
echo "SSL_PORT_START : ${SSL_PORT_START}"
echo "SSL_PORT_END : ${SSL_PORT_END}"

DATA_DIR="/data"

Expand Down Expand Up @@ -73,13 +74,14 @@ start_nginx() {
-e "s:\${V2RAY_PORT}:${V2RAY_PORT}:" \
-e "s:\${V2RAY_WS_PATH}:${V2RAY_WS_PATH}:" \
-e "s:\${SITE_DOMAIN}:${SITE_DOMAIN}:" \
-e "s:\${SSL_PORT}:${SSL_PORT}:" \
-e "s:\${SSL_PORT_START}:${SSL_PORT_START}:" \
-e "s:\${SSL_PORT_END}:${SSL_PORT_END}:" \
-e "s:\${CERTIFICATE_FILE}:${CERTIFICATE_FILE}:" \
-e "s:\${CERTIFICATE_KEY_FILE}:${CERTIFICATE_KEY_FILE}:" \
-e "s:\${DHPARAM_FILE}:${DHPARAM_FILE}:" \
/conf/nginx/nginx.conf >${NGINX_CONF}

echo "starting nginx at port ${SSL_PORT}(https)"
echo "starting nginx at port ${SSL_PORT_START}(https)"
mkdir -p /run/nginx
nginx && echo "nginx started"
}
Expand Down

0 comments on commit d81c9b8

Please sign in to comment.