From e97bbb66c9d1fa229fc2612a33c7abae73120875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E5=B0=8F=E7=99=BD?= <296015668@qq.com> Date: Sun, 8 Oct 2023 13:03:08 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=AE=A2=E6=88=B7=E7=AB=AF=20IP=20=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- compose/docker-compose-lb.yml | 2 +- compose/docker-compose-web.yml | 1 + config-example.txt | 5 +++++ scripts/7_upgrade.sh | 5 +++++ scripts/utils.sh | 3 +-- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/compose/docker-compose-lb.yml b/compose/docker-compose-lb.yml index 1f458f56..e9c5885a 100644 --- a/compose/docker-compose-lb.yml +++ b/compose/docker-compose-lb.yml @@ -11,4 +11,4 @@ services: SSL_CERTIFICATE_KEY: ${SSL_CERTIFICATE_KEY:-} volumes: - ${CONFIG_DIR}/nginx/cert:/etc/nginx/cert - - ${CONFIG_DIR}/nginx/lb_http_server.conf:/etc/nginx/sites-enabled/jumpserver.conf + - ${CONFIG_DIR}/nginx/lb_http_server.conf:/etc/nginx/sites-enabled/https_server.conf diff --git a/compose/docker-compose-web.yml b/compose/docker-compose-web.yml index f532a5ce..4fea4816 100644 --- a/compose/docker-compose-web.yml +++ b/compose/docker-compose-web.yml @@ -13,6 +13,7 @@ services: HTTP_PORT: ${HTTP_PORT:-80} USE_IPV6: ${USE_IPV6:-0} CLIENT_MAX_BODY_SIZE: ${CLIENT_MAX_BODY_SIZE:-4096m} + USE_LB: ${USE_LB:-1} CORE_ENABLED: ${CORE_ENABLED:-1} KOKO_ENABLED: ${KOKO_ENABLED:-1} LION_ENABLED: ${LION_ENABLED:-1} diff --git a/config-example.txt b/config-example.txt index cd15b5af..d9af772b 100644 --- a/config-example.txt +++ b/config-example.txt @@ -148,6 +148,11 @@ XRDP_PORT=3390 # SERVER_HOSTNAME=${HOSTNAME} +# 使用内置 SLB, 如果 Web 页面获取到的客户端 IP 地址不正确, 请将 USE_LB 设置为 0 +# USE_LB 设置为 1 时, 使用配置 proxy_set_header X-Forwarded-For $remote_addr +# USE_LB 设置为 0 时, 使用配置 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for +USE_LB=1 + # 当前运行的 JumpServer 版本号, 安装和升级完成后自动生成 # CURRENT_VERSION= diff --git a/scripts/7_upgrade.sh b/scripts/7_upgrade.sh index 887ebaa9..05115c44 100644 --- a/scripts/7_upgrade.sh +++ b/scripts/7_upgrade.sh @@ -88,6 +88,11 @@ function upgrade_config() { MAGNUS_REDIS_PORT=63790 set_config MAGNUS_REDIS_PORT "${MAGNUS_REDIS_PORT}" fi + use_lb=$(get_config USE_LB) + if [ -z "${use_lb}" ]; then + USE_LB=1 + set_config USE_LB "${USE_LB}" + fi # XPACK use_xpack=$(get_config_or_env USE_XPACK) if [[ "${use_xpack}" == "1" ]]; then diff --git a/scripts/utils.sh b/scripts/utils.sh index a800c569..c2a40d83 100644 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -358,9 +358,8 @@ function get_docker_compose_cmd_line() { if [[ "${services}" =~ minio ]]; then cmd="${cmd} -f compose/docker-compose-minio.yml" fi - use_lb=$(get_config USE_LB) https_port=$(get_config HTTPS_PORT) - if [[ -n "${https_port}" && "${use_lb}" != "0" ]]; then + if [[ -n "${https_port}" ]]; then cmd="${cmd} -f compose/docker-compose-lb.yml" fi use_xpack=$(get_config_or_env USE_XPACK)