I have a rest client written in Spring which uses singleton RestTemplate. I use the same restTemplate to invoke services hosted within intranet and outside of the network (internet). Requests outside of network passes via a proxy.
I have added a proxy in my code as below
SimpleClientHttpRequestFactory simpleClientHttpRequestFactory = SimpleClientHttpRequestFactory) requestFactory;
Proxy proxy = new Proxy(Type.HTTP , new InetSocketAddress(proxyHost, StringUtils.isNotBlank(proxyPort) ? Integer.parseInt(proxyPort) : 80));
simpleClientHttpRequestFactory.setProxy(proxy);
restTemplate.setRequestFactory(simpleClientHttpRequestFactory);
However, with proxy sitting in between, I cannot access services hosted in the same network (intranet). Is there a way to bypass proxy conditionally while invoking actual services?