public static void main(final String[] args)throws Exception {
        final HttpHost target = new HttpHost("https", "httpbin.org", 443);
        final HttpHost proxy = new HttpHost("http", "127.0.0.1", 8080);
        try (final CloseableHttpClient httpclient = HttpClients.custom()
                .setProxy(proxy)
                .build()) {

            final RequestConfig config = RequestConfig.custom()
                    .build();
            final HttpGet request = new HttpGet("/get");
            request.setConfig(config);

            System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
                    " via " + proxy);

            httpclient.execute(target, request, response -> {
                System.out.println("----------------------------------------");
                System.out.println(request + "->" + new StatusLine(response));
                EntityUtils.consume(response.getEntity());
                return null;
            });
        }
    }
How to send a request via proxy.

@since 4.0
httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteProxy.java