Apache ShenYu
serves behind nginx
reverse proxy.IP
and host
, you can match them with plugins and selectors.The embedded implementation in Apache ShenYu
is :org.apache.shenyu.web.forward.ForwardedRemoteAddressResolver
.
You need to config X-Forwarded-For
in nginx
first to get correct IP address
and host
.
CustomRemoteAddressResolver
and implements org.apache.shenyu.plugin.api.RemoteAddressResolver
.public interface RemoteAddressResolver { /** * Resolve inet socket address. * * @param exchange the exchange * @return the inet socket address */ default InetSocketAddress resolve(ServerWebExchange exchange) { return exchange.getRequest().getRemoteAddress(); } }
Spring Bean
.@Bean public RemoteAddressResolver customRemoteAddressResolver() { return new CustomRemoteAddressResolver(); }