Pass actual host arguments to downstream
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e1d0e27c29
commit
f9e7332d2e
|
@ -27,6 +27,8 @@ var contentServers []*content.Server
|
||||||
|
|
||||||
var db *content.Database
|
var db *content.Database
|
||||||
|
|
||||||
|
var redirectListenAddress string
|
||||||
|
|
||||||
func selectNextContentServer(skip []int) *content.Server {
|
func selectNextContentServer(skip []int) *content.Server {
|
||||||
inSkip := func(i int) bool {
|
inSkip := func(i int) bool {
|
||||||
for _, c := range skip {
|
for _, c := range skip {
|
||||||
|
@ -80,6 +82,15 @@ func handle(ctx *httputils.RequestContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
host := ctx.GetRequestHeader("Host")
|
||||||
|
if host == "" && ctx.GetTLSServerName() != "" {
|
||||||
|
host = ctx.GetTLSServerName() + redirectListenAddress
|
||||||
|
}
|
||||||
|
|
||||||
|
if host != "" {
|
||||||
|
host = "/" + host
|
||||||
|
}
|
||||||
|
|
||||||
if ctx.IsGet() || ctx.IsHead() {
|
if ctx.IsGet() || ctx.IsHead() {
|
||||||
if debugOutput {
|
if debugOutput {
|
||||||
log.Printf("Serve %s", ctx.GetPath())
|
log.Printf("Serve %s", ctx.GetPath())
|
||||||
|
@ -170,7 +181,7 @@ func handle(ctx *httputils.RequestContext) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.DoRedirect(contentServer.GetContentURL(entry, privateKey, skip), http.StatusFound)
|
ctx.DoRedirect(contentServer.GetContentURL(entry, privateKey, skip)+host, http.StatusFound)
|
||||||
} else {
|
} else {
|
||||||
contentServer := selectNextContentServer(skip)
|
contentServer := selectNextContentServer(skip)
|
||||||
if contentServer == nil {
|
if contentServer == nil {
|
||||||
|
@ -226,7 +237,7 @@ func handle(ctx *httputils.RequestContext) {
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ctx.DoRedirect(contentServer.GetHashURL(mh, privateKey, skip), http.StatusFound)
|
ctx.DoRedirect(contentServer.GetHashURL(mh, privateKey, skip)+host, http.StatusFound)
|
||||||
}
|
}
|
||||||
} else if ctx.IsOptions() {
|
} else if ctx.IsOptions() {
|
||||||
setOtherHeaders(ctx)
|
setOtherHeaders(ctx)
|
||||||
|
@ -366,5 +377,7 @@ func main() {
|
||||||
Debug: debugOutput,
|
Debug: debugOutput,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
redirectListenAddress = *listenAddress
|
||||||
|
|
||||||
server.Serve()
|
server.Serve()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue