-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proxy configuration not working in Spring Cloud Config #2608
Comments
It sounds like there is a bit of a confusion here. The properties under The config client uses |
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. |
Please find attached a demo to reproduce the issue: demo.zip. |
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
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)
The text was updated successfully, but these errors were encountered: