|
@@ -3,6 +3,8 @@ package com.ym.mec.gateway.web.filter;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import org.bouncycastle.util.IPAddress;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import com.netflix.zuul.ZuulFilter;
|
|
@@ -14,13 +16,15 @@ import java.net.UnknownHostException;
|
|
|
|
|
|
@Component
|
|
|
public class AuthFilter extends ZuulFilter {
|
|
|
+ private static final Logger logger = LoggerFactory.getLogger(AuthFilter.class);
|
|
|
|
|
|
@Override
|
|
|
public Object run() throws ZuulException {//过滤器核心业务方法
|
|
|
+
|
|
|
RequestContext requestContext = RequestContext.getCurrentContext();
|
|
|
HttpServletRequest request = requestContext.getRequest();
|
|
|
String remoteIp = getRealIp(request);
|
|
|
- System.out.println("remoteIp:-------------" + remoteIp);
|
|
|
+ logger.warn("remoteIp:-------------" ,remoteIp);
|
|
|
requestContext.getZuulRequestHeaders().put("HTTP_X_FORWARDED_FOR", remoteIp);
|
|
|
return null;
|
|
|
}
|