website: redirect gerrit to https

Change-Id: I7a61728bb4a02860196235a25d60a8cd07d31668
This commit is contained in:
Brad Fitzpatrick 2011-06-21 11:53:02 -07:00
parent ff87bedcf2
commit de5171b15b
1 changed files with 11 additions and 1 deletions

View File

@ -246,7 +246,17 @@ func main() {
mux.Handle("/talks/", http.FileServer(path.Join(*root, "talks"), "/talks/"))
gerritUrl, _ := http.ParseURL("http://127.0.0.1:8000/")
mux.Handle("/r/", http.NewSingleHostReverseProxy(gerritUrl))
var gerritHandler http.Handler = http.NewSingleHostReverseProxy(gerritUrl)
if *httpsAddr != "" {
gerritHandler = http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
if req.TLS != nil {
gerritHandler.ServeHTTP(rw, req)
return
}
http.Redirect(rw, req, "https://camlistore.org"+req.URL.RawPath, http.StatusFound)
})
}
mux.Handle("/r/", gerritHandler)
testCgi := &cgi.Handler{Path: path.Join(*root, "test.cgi"),
Root: "/test.cgi",