Open moiMeme opened 1 week ago
It sounds like there is a bit of a confusion here.
The properties under spring.cloud.config.server.git.proxy
are used by the CONFIG SERVER to access the Git server through a proxy, it has no effect on the CONFIG CLIENT. Based on your issue it sounds like you are trying to configure the config client to use a proxy to access the config server.
The config client uses RestTemplate
to make requests to the config server so you should be able to follow the Spring Boot documentation for configuring a proxy for the client.
https://docs.spring.io/spring-boot/reference/io/rest-client.html#io.rest-client.resttemplate.customization
I am setting up Spring Cloud Config Server to connect to a Git server through a proxy. The issue arises when using a token for authentication. Upon debugging, I found that the private lookupHttpClientBuilder(url) method fails to locate the HttpClientBuilder by URL.
During configuration, HttpClientConfigurableHttpConnectionFactory creates an HttpClientBuilder and stores it in a Map<String, HttpClientBuilder> httpClientBuildersByUri, where the key is the URL (including the token) from the properties file. However, the lookupHttpClientBuilder method is called with a URL that lacks the token, leading to a lookup failure.
Can you provide a complete, minimal, verifiable sample that reproduces the problem? It should be available as a GitHub (or similar) project or attached to this issue as a zip file.
Describe the bug When configuring a proxy in Spring Cloud Config, HTTP requests to the config server do not route through the specified proxy. Despite setting http.proxyHost and http.proxyPort (or equivalent settings in application.yml), the connection bypasses the proxy and connects directly. This issue impacts users who require proxy routing for secure or restricted network environments.
Step to reproduce
Set up a Spring Boot project with the following dependencies:
Configure the proxy settings in application.yml:
Start the Spring Boot application. Verify if requests to the config server route through the specified proxy (e.g., by checking proxy logs)
Expected Behavior Requests to the config server should be routed through the configured proxy (proxy.example.com:8080).
Actual Behavior Requests to the config server bypass the configured proxy and connect directly. Proxy logs show no incoming requests, confirming that the proxy is not being used.
Environment
Additional Context No related exceptions or errors appear in the logs. The following configurations were tested without success:
Workaround Solution To route requests through the proxy despite the original configuration issue, I extended HttpClientConfigurableHttpConnectionFactory and modified the create method to ensure a new proxy is always created if none is provided or if the proxy type is set to DIRECT. This approach successfully routed requests through the proxy as expected. (not a good solution)
Here’s a summary of the code:
In this method:
If the provided proxy is null or of type DIRECT, it creates a new Proxy instance with Proxy.Type.HTTP and the desired proxy host and port. This successfully routes the request via the specified proxy.(for test purpose)