Spring Cloud OpenFeign Client Using Forward Proxy To Connect To Another MicroService
Spring Cloud OpenFeign Client Proxy Setup To Connect To Another MicroService

Spring Cloud OpenFeign Proxy Setup

Amith Kumar
2 min readMar 12, 2021

--

Spring Cloud OpenFeign supports three underlying implementations for feign client:

You often come across use cases, where the feign client should use an HTTP proxy to make the outbound API call.

Depending on what implementation is used in your project, here is how you configure the feign client to use HTTP proxy:

TRICK: You configure the feign client and then override the default client bean in the Spring application context.

DEFAULT

Comes out of box client with spring cloud, no additional config or dependency is needed:

import feign.Client;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.net.InetSocketAddress;
import java.net.Proxy;
@Configuration
public class FeignConfiguration {
...
@Bean
public Client feignClient() {
return new Client.Proxied(null, null,
new Proxy(Proxy.Type.HTTP,
new InetSocketAddress(proxyHost, proxyPort)));
}
}

ApacheHttpClient

--

--

No responses yet