Add reverse proxy endpoint.

It works by using the Host of the request. When it receives something in
the form of: `<node>.<session>.play-with-docker.com` it does a reverse
proxy http request to `node`, validating that the `node` actually belongs
to the `session`.
If the node has a prefix `ip` and continues with a valid IP address
where the dots where replaces by underscores (like `ip10_0_0_1`) then it
will remove the `ip` prefix and and replace the underscores by dots, and
assume it is an ip address.
This commit is contained in:
Jonathan Leibiusky @xetorthio
2016-11-17 17:37:40 -03:00
parent a85bb4a1d7
commit ec9d34ffda
4 changed files with 57 additions and 0 deletions

3
api.go
View File

@@ -59,6 +59,9 @@ func main() {
r.Handle("/sessions/{sessionId}/ws/", server)
// Reverse proxy
r.Host(`{node}.{session}.play-with-docker.com`).Handler(handlers.NewMultipleHostReverseProxy())
n := negroni.Classic()
n.UseHandler(r)