diff options
author | Christian Pointner <equinox@spreadspace.org> | 2018-02-15 23:50:34 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2018-02-15 23:50:34 +0100 |
commit | cdf8a02ebae501eb0d04a662ca130e3286a1d99f (patch) | |
tree | 20b4c4acd821b606b01e12613a369ceee398aaa4 | |
parent | make sfive stats more flexible (diff) |
add support for multiple backends in config
-rw-r--r-- | src/daq/s5proxy/sample.json | 6 | ||||
-rw-r--r-- | src/daq/s5proxy/src/s5proxy/config.go | 29 | ||||
-rw-r--r-- | src/daq/s5proxy/src/s5proxy/proxy.go | 1 |
3 files changed, 31 insertions, 5 deletions
diff --git a/src/daq/s5proxy/sample.json b/src/daq/s5proxy/sample.json index 664bda4..5200bca 100644 --- a/src/daq/s5proxy/sample.json +++ b/src/daq/s5proxy/sample.json @@ -19,7 +19,7 @@ "secp256r1" ] }, - "connect": "http://emc01.spreadspace.org:8000", + "connect": "http://flumotion-worker-emc-01:8000", "request_header": [ { "op": "del", "header": "X-Forwarded-For" } ], @@ -30,6 +30,10 @@ { "op": "add", "header": "Cache-Control", "value": "max-age=0" }, { "op": "time", "header": "Expires", "value": "-1s" } ], + "locations": { + "/hls/": { "connect": "http://nginx-streamer-emc-01:8000" }, + "/dash/": { "connect": "http://nginx-streamer-emc-01:8000" } + }, "sfive": { "socket": "../../hub/test/pipegram", "hostname": "public1", diff --git a/src/daq/s5proxy/src/s5proxy/config.go b/src/daq/s5proxy/src/s5proxy/config.go index d6e0fa5..12a610f 100644 --- a/src/daq/s5proxy/src/s5proxy/config.go +++ b/src/daq/s5proxy/src/s5proxy/config.go @@ -222,11 +222,18 @@ type Config struct { ListenAddr string `json:"listen"` Protocol ProtocolType `json:"protocol"` Redirect2HTTPS RedirectCode `json:"redirect2https"` - ConnectAddr string `json:"connect"` TLS tlsconfig.TLSConfig `json:"tls"` - RequestHeader []HeaderOperation `json:"request_header"` - ResponseHeader []HeaderOperation `json:"response_header"` - SFive SFiveConf `json:"sfive"` + + ConnectAddr string `json:"connect"` + RequestHeader []HeaderOperation `json:"request_header"` + ResponseHeader []HeaderOperation `json:"response_header"` + Locations map[string]struct { + ConnectAddr string `json:"connect"` + RequestHeader []HeaderOperation `json:"request_header"` + ResponseHeader []HeaderOperation `json:"response_header"` + } `json:"locations"` + + SFive SFiveConf `json:"sfive"` } func readConfig(configfile string) (conf *Config, err error) { @@ -261,5 +268,19 @@ func readConfig(configfile string) (conf *Config, err error) { } } + for k, v := range conf.Locations { + tmp := v + if v.ConnectAddr == "" { + tmp.ConnectAddr = conf.ConnectAddr + } + if len(v.RequestHeader) == 0 { + tmp.RequestHeader = conf.RequestHeader + } + if len(v.ResponseHeader) == 0 { + tmp.ResponseHeader = conf.ResponseHeader + } + conf.Locations[k] = tmp + } + return } diff --git a/src/daq/s5proxy/src/s5proxy/proxy.go b/src/daq/s5proxy/src/s5proxy/proxy.go index cb4c90c..50075c6 100644 --- a/src/daq/s5proxy/src/s5proxy/proxy.go +++ b/src/daq/s5proxy/src/s5proxy/proxy.go @@ -147,6 +147,7 @@ func NewProxy(conf *Config, stats *Stats) (p *Proxy, err error) { } p.mux = http.NewServeMux() + // TODO: add additional handler for conf.Locations p.mux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { proxyHandler(p, w, r) }) |