Fix forward 80 to 443 to not bind on all interfaces. (#8360)

Этот коммит содержится в:
Christopher Speller
2018-02-23 15:33:36 -08:00
коммит произвёл Derrick Anderson
родитель babccba8f8
Коммит 838295f82c

Просмотреть файл

@@ -171,13 +171,17 @@ func (a *App) StartServer() error {
} }
if *a.Config().ServiceSettings.Forward80To443 { if *a.Config().ServiceSettings.Forward80To443 {
if host, _, err := net.SplitHostPort(addr); err != nil {
l4g.Error("Unable to setup forwarding: " + err.Error())
} else {
httpListenAddress := net.JoinHostPort(host, "http")
if *a.Config().ServiceSettings.UseLetsEncrypt { if *a.Config().ServiceSettings.UseLetsEncrypt {
go http.ListenAndServe(":http", m.HTTPHandler(nil)) go http.ListenAndServe(httpListenAddress, m.HTTPHandler(nil))
} else { } else {
go func() { go func() {
redirectListener, err := net.Listen("tcp", ":80") redirectListener, err := net.Listen("tcp", httpListenAddress)
if err != nil { if err != nil {
listener.Close()
l4g.Error("Unable to setup forwarding: " + err.Error()) l4g.Error("Unable to setup forwarding: " + err.Error())
return return
} }
@@ -187,6 +191,7 @@ func (a *App) StartServer() error {
}() }()
} }
} }
}
a.Srv.didFinishListen = make(chan struct{}) a.Srv.didFinishListen = make(chan struct{})
go func() { go func() {