improve error handling around invalid Forward80To443 settings (#8496)
* If Forward80To443 is true, but not configured to listen on 443, fail to start the server with an error message. * If Forward80To443 is false and LetsEncrypt is true, fail to start the server with an error message.
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
67c0efae1b
Коммит
1351874528
@@ -6,6 +6,7 @@ package app
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
@@ -149,8 +150,10 @@ func (a *App) StartServer() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if *a.Config().ServiceSettings.Forward80To443 {
|
if *a.Config().ServiceSettings.Forward80To443 {
|
||||||
if host, _, err := net.SplitHostPort(addr); err != nil {
|
if host, port, err := net.SplitHostPort(addr); err != nil {
|
||||||
l4g.Error("Unable to setup forwarding: " + err.Error())
|
l4g.Error("Unable to setup forwarding: " + err.Error())
|
||||||
|
} else if port != "443" {
|
||||||
|
return fmt.Errorf(utils.T("api.server.start_server.forward80to443.enabled_but_listening_on_wrong_port"), port)
|
||||||
} else {
|
} else {
|
||||||
httpListenAddress := net.JoinHostPort(host, "http")
|
httpListenAddress := net.JoinHostPort(host, "http")
|
||||||
|
|
||||||
@@ -169,6 +172,8 @@ func (a *App) StartServer() error {
|
|||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if *a.Config().ServiceSettings.UseLetsEncrypt {
|
||||||
|
return errors.New(utils.T("api.server.start_server.forward80to443.disabled_while_using_lets_encrypt"))
|
||||||
}
|
}
|
||||||
|
|
||||||
a.Srv.didFinishListen = make(chan struct{})
|
a.Srv.didFinishListen = make(chan struct{})
|
||||||
|
|||||||
@@ -1954,6 +1954,14 @@
|
|||||||
"id": "api.server.new_server.init.info",
|
"id": "api.server.new_server.init.info",
|
||||||
"translation": "Server is initializing..."
|
"translation": "Server is initializing..."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "api.server.start_server.forward80to443.disabled_while_using_lets_encrypt",
|
||||||
|
"translation": "Must enable Forward80To443 when using LetsEncrypt"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "api.server.start_server.forward80to443.enabled_but_listening_on_wrong_port",
|
||||||
|
"translation": "Cannot forward port 80 to port 443 while listening on port %s: disable Forward80To443 if using a proxy server"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "api.server.start_server.listening.info",
|
"id": "api.server.start_server.listening.info",
|
||||||
"translation": "Server is listening on %v"
|
"translation": "Server is listening on %v"
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user