Adding HTTP Proxy to Spring WebFlux Client

What’s the normal way to add http proxy in JVM?

JAVA_FLAGS=-Dhttp.proxyHost= -Dhttp.proxyPort=8888

Similarly, for https

JAVA_FLAGS=-Dhttps.proxyHost= -Dhttps.proxyPort=8888

However, these properties do not work if you are using Spring Webflux Client

There is a bug logged for the same

The proxy support in Spring Webflux client code can only be added through code.

Here is the snippet:

protected WebClient webClient;

public void init() {
   webClient = WebClient.builder().filter(errorHandlingFilter())
                .clientConnector(new ReactorClientHttpConnector(build())).build();

private HttpClient build() {
        HttpClient httpClient = HttpClient.create()
                .tcpConfiguration(tcpClient ->
                        tcpClient.proxy(proxy -> proxy.type(ProxyProvider.Proxy.HTTP).host("").port(8888)));
        return httpClient;