Skip to content
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

Add an experimental transparent HTTP proxy #225

Merged
merged 8 commits into from
May 26, 2017
Merged

Conversation

djs55
Copy link
Collaborator

@djs55 djs55 commented May 24, 2017

If the key slirp/http-intercept is provided then

  • all outgoing traffic on port 80 will be proxied at the HTTP level rather than the TCP level.
  • all outgoing traffic on port 443 will be proxied via HTTP CONNECT

This has the advantage that the client doesn't need to know it's being proxied or the address of the proxy, so that if the client moves on the network everything continues to work.

Note that normally a client knows that it is talking to a proxy and sends slightly different requests: in particular it will use an absolute URI for the resource (e.g. GET http://dave.recoil.org/ rather than GET /) and it will expect the proxy to behave like a proxy. Since we are trying to pretend we don't exist we try to be as transparent as possible and only change the resource URI.

This PR works for simple cases such as apk update and plain curl/wget. Test cases are provided which compare the proxied request to the original.

This PR currently doesn't handle exclusions: we need to decide on the expressivity (e.g. wildcards and CIDRs)

Related to #20

@djs55 djs55 force-pushed the http-intercept branch 2 times, most recently from d7c07bb to f363c02 Compare May 25, 2017 15:27
djs55 added 2 commits May 26, 2017 15:16
If the key `slirp/http-intercept` is provided, then its contents are
parsed as json and interpreted as transparent proxy settings e.g.

  {
    "http": "http://docker.com:3128",
    "https": "http://docker.com:3128",
    "excludes": ""
  }

means to forward both HTTP and HTTPs to http://docker.com:3128.

The proxied request should be identical to the original request, except
that the resource will have been transformed from a relative URI (e.g. `/`)
into an absolute one (e.g. `http://dave.recoil.org/`).

The address of a proxy can take any of the following forms:

  ip:port
  host:port
  http://host:port
  http://ip:port

There is currently no support for the `excludes` key.

Signed-off-by: David Scott <[email protected]>
This enables HTTP interception and checks that

- requests are captured
- resources are converted to absolute URIs
- headers of various kinds are preserved

Signed-off-by: David Scott <[email protected]>
@djs55 djs55 force-pushed the http-intercept branch from 436d15f to 0f7b0c5 Compare May 26, 2017 14:51
djs55 added 6 commits May 26, 2017 16:05
If `http-intercept` is set and there is an upstream https proxy,
then all outgoing traffic to port 443 will be proxied at the TCP
level through a HTTP CONNECT.

Signed-off-by: David Scott <[email protected]>
These tests appear to block on appveyor.

As a general rule we don't re-run the unit tests of all our dependencies
here, but we make a special exception for tcpip which we have heavily
modified. This patch installs and runs the tests for tcpip first, before
installing (without tests) all the other dependencies.

Signed-off-by: David Scott <[email protected]>
@djs55 djs55 force-pushed the http-intercept branch from 0f7b0c5 to e6437ea Compare May 26, 2017 15:05
@djs55 djs55 merged commit 66a25d6 into moby:master May 26, 2017
@djs55 djs55 deleted the http-intercept branch May 26, 2017 15:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant