public class XForwardedRemoteAddressResolver extends Object implements RemoteAddressResolver
RemoteAddressResolver and
ServerHttpRequest.getRemoteAddress(). Use the static constructor methods which
meets your security requirements.| 限定符和类型 | 字段和说明 |
|---|---|
static String |
X_FORWARDED_FOR
Forwarded-For header name.
|
| 构造器和说明 |
|---|
XForwardedRemoteAddressResolver(int maxTrustedIndex) |
| 限定符和类型 | 方法和说明 |
|---|---|
static XForwardedRemoteAddressResolver |
maxTrustedIndex(int maxTrustedIndex)
trusted IP address found in the X-Forwarded-For header (when present).
|
InetSocketAddress |
resolve(org.springframework.web.server.ServerWebExchange exchange)
The X-Forwarded-For header contains a comma separated list of IP addresses.
|
static XForwardedRemoteAddressResolver |
trustAll() |
public static XForwardedRemoteAddressResolver trustAll()
XForwardedRemoteAddressResolver which always extracts the first
IP address found in the X-Forwarded-For header (when present). Equivalent to
calling maxTrustedIndex(int) with a maxTrustedIndex of
Integer.MAX_VALUE. This configuration is vulnerable to spoofing via
manually setting the X-Forwarded-For header. If the resulting IP address is used
for security purposes, use maxTrustedIndex(int) instead.public static XForwardedRemoteAddressResolver maxTrustedIndex(int maxTrustedIndex)
maxTrustedIndex - correlates to the number of trusted proxies expected in
front of Spring Cloud Gateway (index starts at 1).XForwardedRemoteAddressResolver which extracts the lastpublic InetSocketAddress resolve(org.springframework.web.server.ServerWebExchange exchange)
resolve 在接口中 RemoteAddressResolverexchange - the exchangeCopyright © 2019 dromara. All rights reserved.