Skip to content
This repository has been archived by the owner on Mar 21, 2022. It is now read-only.

Enable Proxy support #742

Closed
shrids opened this issue May 14, 2017 · 3 comments
Closed

Enable Proxy support #742

shrids opened this issue May 14, 2017 · 3 comments

Comments

@shrids
Copy link
Contributor

shrids commented May 14, 2017

Currently com.spotify.docker.client.DefaultDockerClient does not provide a way to configure http proxy.
We could add something on the following lines so that the internal jaxws.rs client has proxy configured.

final ClientConfig config = DEFAULT_CONFIG
        .connectorProvider(new ApacheConnectorProvider())
        .property(ApacheClientProperties.CONNECTION_MANAGER, cm)
        .property(ApacheClientProperties.REQUEST_CONFIG, requestConfig)
        .property(ClientProperties.PROXY_URI, proxy);
        .property(ClientProperties.PROXY_USERNAME,user);
        .property(ClientProperties.PROXY_PASSWORD,pass);
@mattnworb
Copy link
Member

Any idea if the Jersey/ApacheConnectorProvider will respect system properties like -Dhttp.proxyHost, like the `java.net. package does? If not that is a bummer.

Would you be willing to create a PR that adds these properties to the DefaultDockerClient.Builder class? that seems like the most natural place to configure this if the system properties aren't read by Jersey.

@shrids
Copy link
Contributor Author

shrids commented May 16, 2017

System properties like http.proxyHost are not read by Jersey. Added the following snippet inside the package private constructor of DefaultDockerClient.

    final String proxyHost = System.getProperty("http.proxyHost");
    if (proxyHost != null) {
      config.property(ClientProperties.PROXY_URI, proxyHost + ":"
              + System.getProperty("http.proxyPort", "8080"));
    }

This change ensured all the HTTP GET requests to dockerd works. But all POST requests to dockerd throws an EOF error (error snippet below) . Wondering if it is a setup issue or a proxy issue.
docker[21429]: time="2017-05-16T08:31:05.692109391Z" level=error msg="Handler for POST /containers/create returned error: EOF"

I have a docker daemon which supports 1.24 api version. dockerD version is 1.12.6

@shrids
Copy link
Contributor Author

shrids commented May 18, 2017

Found the reason why POST failed while using tinyproxy. (tinyproxy/tinyproxy#58)
To solve this we need to ensure content-length is populated by jersey client. This can be done by setting the following additional property in jersey client
config.property(ClientProperties.REQUEST_ENTITY_PROCESSING, RequestEntityProcessing.BUFFERED);
With this change it is working fine...

shrids added a commit to shrids/docker-client that referenced this issue May 31, 2017
mattnworb pushed a commit that referenced this issue Jun 6, 2017
* Fixes #742 , enable http proxy support for docker-client

* CR changes: replace default port of 8080 with Preconditions.checkNotNull(...)

* CR Changes: Update CHANGELOG.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants