diff --git a/bin/tsw/util/http.js b/bin/tsw/util/http.js index ce8f918e..c554403a 100644 --- a/bin/tsw/util/http.js +++ b/bin/tsw/util/http.js @@ -416,7 +416,13 @@ this.getUserIp = function(request) { const qvia = request.headers['qvia'] || ''; const realIp = request.headers['x-real-ip'] || ''; - if (xff) { + if (realIp) { + + // x-real-ip + if (userIp && this.isInnerIP(userIp)) { + userIp = realIp; + } + } else if (xff) { // xff判断,注意只认内网ip带的xff,外网带的不算 if (userIp && this.isInnerIP(userIp)) { @@ -425,12 +431,6 @@ this.getUserIp = function(request) { userIp = xff.trim() || userIp; } - } else if (realIp) { - - // x-real-ip - if (userIp && this.isInnerIP(userIp)) { - userIp = realIp; - } } else if (qvia) { // 注意只认内网ip带的qvia,外网带的不算