Well after struggling a lot with Micronaut to dompted our proxies, I came to the idea to write a Spring Boot Application doing for the same purpose.
For Spring Boot the HTTP proxy configuration is really straight forward and there are a lot examples available. I came out with this example:
application.properties
generic.proxyHost = my.corporateproxy.net
generic.proxyPort = 3128
MyController.java
@Value("${generic.proxyHost}")
private String proxyHost;
@Value("${generic.proxyPort}")
private Integer proxyPort;
@GetMapping("/proxy")
public HttpStatus getApiWithProxy(){
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
InetSocketAddress address = new InetSocketAddress(proxyHost, proxyPort);
Proxy proxy = new Proxy(Proxy.Type.HTTP, address);
factory.setProxy(proxy);
RestTemplate restTemplate = new RestTemplate();
restTemplate.setRequestFactory(factory);
ResponseEntity<String> response = restTemplate.getForEntity("https://any.api.returningstring.net/", String.class);
return response.getStatusCode();
}
This way actually works, I tried to translate this listing to Micronaut extending for example the HttpClientConfiguration. Without any success.
Is there any solution to set proxy and passing it programmatically to the HttpClient in Micronaut?
P.S: This spring boot application is launched as Docker Container in our corporate Cloud (Kubernetes). The micronaut have to replace it, but we stuck at how to set the proxies.