Commit 96672c5e authored by Jacob Vosmaer's avatar Jacob Vosmaer

Set relative URL via -authBackend

parent af9e7622
......@@ -36,7 +36,6 @@ var listenUmask = flag.Int("listenUmask", 022, "Umask for Unix socket, default:
var authBackend = flag.String("authBackend", "http://localhost:8080", "Authentication/authorization backend")
var authSocket = flag.String("authSocket", "", "Optional: Unix domain socket to dial authBackend at")
var pprofListenAddr = flag.String("pprofListenAddr", "", "pprof listening address, e.g. 'localhost:6060'")
var relativeURLRoot = flag.String("relativeURLRoot", "/", "GitLab relative URL root")
var documentRoot = flag.String("documentRoot", "public", "Path to static files content")
var responseHeadersTimeout = flag.Duration("proxyHeadersTimeout", time.Minute, "How long to wait for response headers when proxying the request")
var developmentMode = flag.Bool("developmentMode", false, "Allow to serve assets from Rails app")
......@@ -170,6 +169,5 @@ func main() {
}
upstream := newUpstream(*authBackend, proxyTransport)
upstream.SetRelativeURLRoot(*relativeURLRoot)
log.Fatal(http.Serve(listener, upstream))
}
......@@ -68,25 +68,22 @@ func newUpstream(authBackend string, authTransport http.RoundTripper) *upstream
if err != nil {
log.Fatalln(err)
}
relativeURLRoot := u.Path
if !strings.HasSuffix(relativeURLRoot, "/") {
relativeURLRoot += "/"
}
u.Path = "" // Would cause redirect loop in ReverseProxy
up := &upstream{
authBackend: authBackend,
httpClient: &http.Client{Transport: authTransport},
httpProxy: httputil.NewSingleHostReverseProxy(u),
relativeURLRoot: "/",
relativeURLRoot: relativeURLRoot,
}
up.httpProxy.Transport = authTransport
return up
}
func (u *upstream) SetRelativeURLRoot(relativeURLRoot string) {
u.relativeURLRoot = relativeURLRoot
if !strings.HasSuffix(u.relativeURLRoot, "/") {
u.relativeURLRoot += "/"
}
}
func (u *upstream) ServeHTTP(ow http.ResponseWriter, r *http.Request) {
var g httpRoute
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment