From bbc9ee120d6112c2364a5e69ee3178f279923674 Mon Sep 17 00:00:00 2001 From: hanhh <18330117883@163.com> Date: Sun, 22 Aug 2021 14:07:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96=E8=AE=BF?= =?UTF-8?q?=E9=97=AEip=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- back/config/util.ts | 4 +++- docker/front.conf | 2 +- src/pages/login/index.tsx | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/back/config/util.ts b/back/config/util.ts index 7ca85a8f..cb0c98ea 100644 --- a/back/config/util.ts +++ b/back/config/util.ts @@ -132,7 +132,8 @@ export async function getNetIp(req: any) { ]), ]; let ip = ipArray[0]; - console.log(ipArray); + console.log(`访问的ip ${ipArray.toString()}`); + if (ipArray.length > 1) { for (let i = 0; i < ipArray.length; i++) { const ipNumArray = ipArray[i].split('.'); @@ -148,6 +149,7 @@ export async function getNetIp(req: any) { continue; } ip = ipArray[i]; + break; } } ip = ip.substr(ip.lastIndexOf(':') + 1, ip.length); diff --git a/docker/front.conf b/docker/front.conf index 7a014e88..1dd6c555 100644 --- a/docker/front.conf +++ b/docker/front.conf @@ -10,7 +10,7 @@ server { location /api { 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_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://api; } diff --git a/src/pages/login/index.tsx b/src/pages/login/index.tsx index a8046beb..7ec86fbd 100644 --- a/src/pages/login/index.tsx +++ b/src/pages/login/index.tsx @@ -37,13 +37,14 @@ const Login = () => { notification.success({ message: '登录成功!', description: ( -