const headers = req.headers; const ip = headers['x-real-ip'] as string || headers['x-forwarded-for'] as string || // 判断是否有反向代理 IP req.connection.remoteAddress || // 判断 connection 的远程 IP req.socket.remoteAddress; // 判断后端的 socket 的 IP