From 8469b44adf35c33489d2006d8b92b52ed1a40fa6 Mon Sep 17 00:00:00 2001 From: Bai Date: Fri, 27 Mar 2026 16:30:36 +0800 Subject: [PATCH] perf: support ws_port --- includes/core.conf | 2 +- init.sh | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/includes/core.conf b/includes/core.conf index da07973..364fd0e 100644 --- a/includes/core.conf +++ b/includes/core.conf @@ -8,7 +8,7 @@ location /private-media/ { } location /ws/ { - set $core_upstream core:8080; + set $core_upstream core:WS_LISTEN_PORT; proxy_pass http://$core_upstream; proxy_buffering off; proxy_http_version 1.1; diff --git a/init.sh b/init.sh index 35032f5..375d298 100755 --- a/init.sh +++ b/init.sh @@ -146,6 +146,21 @@ function config_gzip() { fi } +function config_ws_listen_port() { + core_config_file=/etc/nginx/includes/core.conf + if [ ! -f "${core_config_file}" ]; then + return + fi + + ws_listen_port=${WS_LISTEN_PORT:-8080} + if [[ ! "${ws_listen_port}" =~ ^[0-9]+$ ]]; then + echo "Invalid WS_LISTEN_PORT: ${WS_LISTEN_PORT}, fallback to 8080" + ws_listen_port=8080 + fi + + sed -i "s@core:WS_LISTEN_PORT;@core:${ws_listen_port};@g" "${core_config_file}" +} + function main() { if [ -f "/etc/nginx/sites-enabled/jms.conf" ]; then config_helm @@ -157,6 +172,7 @@ function main() { config_https fi config_components + config_ws_listen_port if [ -f "/etc/init.d/cron" ]; then /etc/init.d/cron start