Make HttpClientProperties#proxy customizable
Fixes gh-2140
This commit is contained in:
@@ -80,6 +80,7 @@
|
||||
|spring.cloud.gateway.httpclient.pool.max-life-time | | Duration after which the channel will be closed. If NULL, there is no max life time.
|
||||
|spring.cloud.gateway.httpclient.pool.name | `proxy` | The channel pool map name, defaults to proxy.
|
||||
|spring.cloud.gateway.httpclient.pool.type | | Type of pool for HttpClient to use, defaults to ELASTIC.
|
||||
|spring.cloud.gateway.httpclient.proxy.type | `HTTP` | proxyType for proxy configuration of Netty HttpClient.
|
||||
|spring.cloud.gateway.httpclient.proxy.host | | Hostname for proxy configuration of Netty HttpClient.
|
||||
|spring.cloud.gateway.httpclient.proxy.non-proxy-hosts-pattern | | Regular expression (Java) for a configured list of hosts. that should be reached directly, bypassing the proxy
|
||||
|spring.cloud.gateway.httpclient.proxy.password | | Password for proxy configuration of Netty HttpClient.
|
||||
@@ -140,4 +141,4 @@
|
||||
|spring.cloud.gateway.x-forwarded.proto-append | `true` | If appending X-Forwarded-Proto as a list is enabled.
|
||||
|spring.cloud.gateway.x-forwarded.proto-enabled | `true` | If X-Forwarded-Proto is enabled.
|
||||
|
||||
|===
|
||||
|===
|
||||
|
||||
@@ -692,8 +692,7 @@ public class GatewayAutoConfiguration {
|
||||
if (StringUtils.hasText(proxy.getHost())) {
|
||||
|
||||
tcpClient = tcpClient.proxy(proxySpec -> {
|
||||
ProxyProvider.Builder builder = proxySpec.type(ProxyProvider.Proxy.HTTP)
|
||||
.host(proxy.getHost());
|
||||
ProxyProvider.Builder builder = proxySpec.type(proxy.getType()).host(proxy.getHost());
|
||||
|
||||
PropertyMapper map = PropertyMapper.get();
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import javax.validation.constraints.Max;
|
||||
|
||||
import reactor.netty.resources.ConnectionProvider;
|
||||
import reactor.netty.tcp.SslProvider;
|
||||
import reactor.netty.transport.ProxyProvider;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.web.server.WebServerException;
|
||||
@@ -288,6 +289,9 @@ public class HttpClientProperties {
|
||||
|
||||
public static class Proxy {
|
||||
|
||||
/** proxyType for proxy configuration of Netty HttpClient. */
|
||||
private ProxyProvider.Proxy type = ProxyProvider.Proxy.HTTP;
|
||||
|
||||
/** Hostname for proxy configuration of Netty HttpClient. */
|
||||
private String host;
|
||||
|
||||
@@ -306,6 +310,14 @@ public class HttpClientProperties {
|
||||
*/
|
||||
private String nonProxyHostsPattern;
|
||||
|
||||
public ProxyProvider.Proxy getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(ProxyProvider.Proxy type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getHost() {
|
||||
return host;
|
||||
}
|
||||
@@ -348,8 +360,9 @@ public class HttpClientProperties {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Proxy{" + "host='" + host + '\'' + ", port=" + port + ", username='" + username + '\''
|
||||
+ ", password='" + password + '\'' + ", nonProxyHostsPattern='" + nonProxyHostsPattern + '\'' + '}';
|
||||
return "Proxy{" + "type='" + type + '\'' + "host='" + host + '\'' + ", port=" + port + ", username='"
|
||||
+ username + '\'' + ", password='" + password + '\'' + ", nonProxyHostsPattern='"
|
||||
+ nonProxyHostsPattern + '\'' + '}';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user