Don't try to guess listening address
Always listen on all hosts. Only use the host part of a frontend address for TLS cert names. Customizing the listen host will be better done with a `bind` directive, like Caddy does.
This commit is contained in:
parent
fd46214036
commit
18dd507ea5
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
configPath = "config"
|
configPath = "config"
|
||||||
certDataPath = ""
|
certDataPath = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -38,25 +38,21 @@ func parseFrontend(srv *Server, d *Directive) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, listenAddr := range d.Params {
|
for _, addr := range d.Params {
|
||||||
host, port, err := net.SplitHostPort(listenAddr)
|
host, port, err := net.SplitHostPort(addr)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to parse listen address %q: %v", listenAddr, err)
|
return fmt.Errorf("failed to parse frontend address %q: %v", addr, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: come up with something more robust
|
if host != "" {
|
||||||
var name string
|
srv.ManagedNames = append(srv.ManagedNames, host)
|
||||||
if host != "" && host != "localhost" && net.ParseIP(host) == nil {
|
|
||||||
name = host
|
|
||||||
host = ""
|
|
||||||
|
|
||||||
srv.ManagedNames = append(srv.ManagedNames, name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr := net.JoinHostPort(host, port)
|
// TODO: allow to customize listen host
|
||||||
|
addr := net.JoinHostPort("", port)
|
||||||
|
|
||||||
ln := srv.RegisterListener(addr)
|
ln := srv.RegisterListener(addr)
|
||||||
if err := ln.RegisterFrontend(name, frontend); err != nil {
|
if err := ln.RegisterFrontend(host, frontend); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue