camweb: added reverse proxy for the build bot server

Change-Id: I9e1c8b0e2d28f9f7660763ecbd3f8be149dfe716
This commit is contained in:
mpl 2013-01-14 23:33:49 +01:00
parent dd72cd4434
commit 58f33f0b12
1 changed files with 14 additions and 2 deletions

View File

@ -52,12 +52,14 @@ var (
tlsKeyFile = flag.String("tlskey", "", "TLS private key file")
gerritUser = flag.String("gerrituser", "ubuntu", "Gerrit host's username")
gerritHost = flag.String("gerrithost", "", "Gerrit host, or empty.")
buildbotBackend = flag.String("buildbot_backend", "", "Build bot status backend.")
buildbotHost = flag.String("buildbot_host", "", "Hostname to map to the buildbot_backend. If an HTTP request with this hostname is received, it proxies to buildbot_backend.")
pageHtml, errorHtml *template.Template
)
var fmap = template.FuncMap{
"": textFmt,
"html": htmlFmt,
"": textFmt,
"html": htmlFmt,
"htmlesc": htmlEscFmt,
}
@ -321,6 +323,16 @@ func main() {
}
mux.HandleFunc("/", mainHandler)
if *buildbotHost != "" && *buildbotBackend != "" {
buildbotUrl, err := url.Parse(*buildbotBackend)
if err != nil {
log.Fatalf("Failed to parse %v as a URL: %v", *buildbotBackend, err)
}
buildbotHandler := httputil.NewSingleHostReverseProxy(buildbotUrl)
bbhpattern := strings.TrimRight(*buildbotHost, "/") + "/"
mux.Handle(bbhpattern, buildbotHandler)
}
var handler http.Handler = &noWwwHandler{Handler: mux}
if *logDir != "" || *logStdout {
handler = NewLoggingHandler(handler, *logDir, *logStdout)