From 24e7ed38a5de3f740155d9ad6ba9b649371d8f20 Mon Sep 17 00:00:00 2001 From: TwelveT <2471835953@qq.com> Date: Sun, 7 Mar 2021 23:47:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0feign=E5=AE=A2=E6=88=B7?= =?UTF-8?q?=E7=AB=AFIP=E5=A4=B4=E9=83=A8=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/security/feign/FeignRequestInterceptor.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java index 2642dd12..50539f33 100644 --- a/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java +++ b/ruoyi-common/ruoyi-common-security/src/main/java/com/ruoyi/common/security/feign/FeignRequestInterceptor.java @@ -2,6 +2,8 @@ package com.ruoyi.common.security.feign; import java.util.Map; import javax.servlet.http.HttpServletRequest; + +import com.ruoyi.common.core.utils.ip.IpUtils; import org.springframework.stereotype.Component; import com.ruoyi.common.core.constant.CacheConstants; import com.ruoyi.common.core.utils.ServletUtils; @@ -40,6 +42,10 @@ public class FeignRequestInterceptor implements RequestInterceptor { requestTemplate.header(CacheConstants.AUTHORIZATION_HEADER, authentication); } + + // 配置客户端IP + requestTemplate.header("X-Forwarded-For", IpUtils.getIpAddr(ServletUtils.getRequest())); + } } } \ No newline at end of file