本文共 1466 字,大约阅读时间需要 4 分钟。
location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://127.0.0.1:8360/; } var getIp = function(_http) { var ipStr = _http.headers['X-Real-IP'] || _http.headers['x-forwarded-for']; if (ipStr) { var ipArray = ipStr.split(","); if (ipArray && ipArray.length > 0) { return ipArray[0]; } } else { return _http.ip().substring(_http.ip().lastIndexOf(":") + 1); } }; var getNetIp = function(_http) { var ipStr = _http.headers['X-Real-IP'] || _http.headers['x-forwarded-for']; if (ipStr) { var ipArray = ipStr.split(","); if (ipArray.length > 1) { for (var i = 0; i < ipArray.length; i++) { var ipNumArray = ipArray[i].split("."); var tmp = ipNumArray[0] + "." + ipNumArray[1]; if (tmp == "192.168" || (ipNumArray[0] == "172" && ipNumArray[1] >= 16 && ipNumArray[1] <= 32) || tmp == "10.7") { continue; } return ipArray[i]; } } return ipArray[0]; } else { return _http.ip().substring(_http.ip().lastIndexOf(":") + 1); } }; 转载地址:http://ctjfk.baihongyu.com/