Skip to content

Commit

Permalink
perf: 优化获取客户端 IP 地址
Browse files Browse the repository at this point in the history
  • Loading branch information
wojiushixiaobai committed Oct 8, 2023
1 parent ca89d06 commit e97bbb6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compose/docker-compose-lb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions compose/docker-compose-web.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
5 changes: 5 additions & 0 deletions config-example.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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=
5 changes: 5 additions & 0 deletions scripts/7_upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions scripts/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit e97bbb6

Please sign in to comment.