Build a Vert.x WebClient with Its ProxyOptions
Configure an explicit HTTP proxy when constructing a Vert.x 4.5 WebClient and keep destination requests addressed to the service.
ProxyOptions proxy = new ProxyOptions()
.setType(ProxyType.HTTP)
.setHost("proxy.example")
.setPort(8080);
WebClient client = WebClient.create(vertx,
new WebClientOptions().setProxyOptions(proxy));
client.getAbs("https://example.com/").send()
.onSuccess(response -> System.out.println(response.statusCode()))
.onFailure(Throwable::printStackTrace);
For Vert.x 4.5.7, this assumes an existing Vertx instance and the corresponding core/WebClient classes. The request URL is still the website; ProxyOptions selects the intermediary. Choose an HTTP endpoint from the HTTP proxy list for this public-site example when that route is allowed and no proxy account is required.
If deployment values come from JVM properties, read and validate them before constructing these options. A value present in System does not establish that this client imported it.
Choose the endpoint's required proxy type and use supported username/password fields if needed. Preserve normal target TLS verification for HTTPS.
Reuse this client for its workload and close it afterward. Constructing another configured client does not affect requests still sent through an older instance.