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

Simple tcp to socket multiplexing reverse proxy #438

Merged
merged 8 commits into from
Mar 25, 2017

Conversation

chungers
Copy link
Contributor

@chungers chungers commented Mar 20, 2017

This PR adds a simple mux reverse proxy that can listen on a tcp port and multiplexes requests to the plugins that it is able to communicate with.

For each HTTP request, the mux proxy will look at the URL of the request. The URL of the form

http://<host>:<port>/<plugin_name>/path/to/something

It will locate the plugin plugin_name and forward the request with the plugin_name stripped. This makes it possible for the user to start a server to act as an API gateway so that a remote CLI orr web application / dashboard UI can access the infrakit plugin API.

Over time, we will add auth and forwarding (to master) to this mux frontend so that it becomes a single point of contact for accessing infrakit SPI remotely. We may choose to limit the JSON RPC methods that are exposed by filtering the requests.

Now the infrakit CLI also supports accessing remote infrakit plugins via the -H options similar to docker -H <host>. You can add multiple proxy endpoints in the case of HA setup and the infrakit CLI will automatically determine the leader node and uses the mux proxy on the leader for all communications. This behavior is dynamic, so as long as the original set of host endpoint provided does not change (ie stable IP addresses and ports for members of an infrakit HA setup), the remote infrakit cli will follow the leader as leadership changes due to failover, etc.

Signed-off-by: David Chung david.chung@docker.com

Signed-off-by: David Chung <david.chung@docker.com>
@codecov
Copy link

codecov bot commented Mar 20, 2017

Codecov Report

Merging #438 into master will decrease coverage by 0.57%.
The diff coverage is 50.24%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #438      +/-   ##
==========================================
- Coverage   69.91%   69.33%   -0.58%     
==========================================
  Files          68       70       +2     
  Lines        3925     4093     +168     
==========================================
+ Hits         2744     2838      +94     
- Misses        935      994      +59     
- Partials      246      261      +15
Impacted Files Coverage Δ
pkg/rpc/server/server.go 55.69% <0%> (-1.45%) ⬇️
pkg/discovery/discovery.go 30% <30%> (+30%) ⬆️
pkg/rpc/mux/reverse_proxy.go 54.08% <54.08%> (ø)
pkg/rpc/mux/server.go 59.52% <59.52%> (ø)
pkg/rpc/client/client.go 62.96% <70.37%> (-0.68%) ⬇️
pkg/discovery/dir.go 48.43% <8.33%> (-22.4%) ⬇️
pkg/broker/client/sse.go 65.11% <0%> (+3.48%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8582433...b9b558a. Read the comment docs.

@GordonTheTurtle
Copy link

Please sign your commits following these rules:
https://github.com/docker/docker/blob/master/CONTRIBUTING.md#sign-your-work
The easiest way to do this is to amend the last commit:

$ git clone -b "mux-proxy" git@github.com:chungers/infrakit.git somewhere
$ cd somewhere
$ git rebase -i HEAD~842353905672
editor opens
change each 'pick' to 'edit'
save the file and quit
$ git commit --amend -s --no-edit
$ git rebase --continue # and repeat the amend for each commit
$ git push -f

Amending updates the existing PR. You DO NOT need to open a new one.

@chungers chungers changed the title [WIP] Simple tcp to socket multiplexing reverse proxy Simple tcp to socket multiplexing reverse proxy Mar 25, 2017
@chungers chungers merged commit c569045 into docker-archive:master Mar 25, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants