modified: server.js
This commit is contained in:
parent
23a77d6868
commit
ff25ff639a
@ -304,13 +304,20 @@ function getClientIP(req) {
|
||||
console.log("x-client-ip:", req.headers["x-client-ip"]);
|
||||
console.log("req.connection.remoteAddress:", req.connection?.remoteAddress);
|
||||
console.log("req.socket.remoteAddress:", req.socket?.remoteAddress);
|
||||
console.log("ALL HEADERS:", JSON.stringify(req.headers, null, 2));
|
||||
console.log("========================");
|
||||
|
||||
// Проверяем X-Forwarded-For заголовок в первую очередь
|
||||
let ip = req.headers["x-forwarded-for"]?.split(",")[0].trim();
|
||||
|
||||
// Если X-Forwarded-For не определен, пробуем другие заголовки
|
||||
if (!ip || ip === "127.0.0.1" || ip === "::1" || ip === "::ffff:127.0.0.1") {
|
||||
if (
|
||||
!ip ||
|
||||
ip === "127.0.0.1" ||
|
||||
ip === "::1" ||
|
||||
ip === "::ffff:127.0.0.1" ||
|
||||
ip === "172.17.0.1"
|
||||
) {
|
||||
ip =
|
||||
req.headers["x-real-ip"] ||
|
||||
req.headers["x-client-ip"] ||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user