Use CertMagic's HTTP and HTTPS port variable

Slightly inconvenient because it uses int type and we use string, but
oh well. This fixes a bug related to setting -http-port and -https-port
flags which weren't being used by CertMagic in some cases.
This commit is contained in:
Matthew Holt
2019-06-19 16:55:27 -06:00
parent 6720bdfb55
commit 721c100bb0
3 changed files with 34 additions and 27 deletions
+3 -1
View File
@@ -25,6 +25,7 @@ import (
"net/http"
"net/url"
"path"
"strconv"
"strings"
"sync"
"text/template"
@@ -33,6 +34,7 @@ import (
"os"
"github.com/mholt/caddy/caddytls"
"github.com/mholt/certmagic"
"github.com/russross/blackfriday"
)
@@ -178,7 +180,7 @@ func (c Context) Port() (string, error) {
if err != nil {
if !strings.Contains(c.Req.Host, ":") {
// common with sites served on the default port 80
return HTTPPort, nil
return strconv.Itoa(certmagic.HTTPPort), nil
}
return "", err
}