mirror of
https://github.com/bingohuang/docker-labs.git
synced 2025-07-14 01:57:32 +08:00
Make regex more restrictive to allow the proxy to be more deterministic.
Make it to not depend on a specific TLD.
This commit is contained in:
parent
b4ce06fa20
commit
6af6f42721
11
api.go
11
api.go
@ -36,6 +36,12 @@ func main() {
|
||||
}
|
||||
|
||||
r := mux.NewRouter()
|
||||
|
||||
// Reverse proxy (needs to be the first route, to make sure it is the first thing we check)
|
||||
proxyHandler := handlers.NewMultipleHostReverseProxy()
|
||||
r.Host(`{node:ip[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}}-{port:[0-9]*}.{tld:.*}`).Handler(proxyHandler)
|
||||
r.Host(`{node:ip[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}_[0-9]{1,3}}.{tld:.*}`).Handler(proxyHandler)
|
||||
|
||||
r.StrictSlash(false)
|
||||
|
||||
r.HandleFunc("/ping", http.HandlerFunc(handlers.Ping)).Methods("GET")
|
||||
@ -59,11 +65,6 @@ func main() {
|
||||
|
||||
r.Handle("/sessions/{sessionId}/ws/", server)
|
||||
|
||||
// Reverse proxy
|
||||
proxyHandler := handlers.NewMultipleHostReverseProxy()
|
||||
r.Host(`{node}-{port:[0-9]*}.play-with-docker.com`).Handler(proxyHandler)
|
||||
r.Host(`{node}.play-with-docker.com`).Handler(proxyHandler)
|
||||
|
||||
n := negroni.Classic()
|
||||
n.UseHandler(r)
|
||||
|
||||
|
@ -108,12 +108,14 @@ func NewSession() (*Session, error) {
|
||||
log.Println("ERROR NETWORKING")
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("Network [%s] created for session [%s]\n", s.Id, s.Id)
|
||||
|
||||
// Connect PWD daemon to the new network
|
||||
if err := ConnectNetwork("pwd", s.Id); err != nil {
|
||||
log.Println("ERROR NETWORKING")
|
||||
return nil, err
|
||||
}
|
||||
log.Printf("Connected pwd to network [%s]\n", s.Id)
|
||||
|
||||
// We store sessions as soon as we create one so we don't delete new sessions on an api restart
|
||||
if err := saveSessionsToDisk(); err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user