diff --git a/docs/src/main/asciidoc/_configprops.adoc b/docs/src/main/asciidoc/_configprops.adoc index 49a37edc..abbea0fb 100644 --- a/docs/src/main/asciidoc/_configprops.adoc +++ b/docs/src/main/asciidoc/_configprops.adoc @@ -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. -|=== \ No newline at end of file +|=== diff --git a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java index 9c327874..e06b6b4d 100644 --- a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java +++ b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/GatewayAutoConfiguration.java @@ -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(); diff --git a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java index 13c98509..53d3470b 100644 --- a/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java +++ b/spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/config/HttpClientProperties.java @@ -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 + '\'' + '}'; } }