Skip to content

Commit 2dbabfa

Browse files
authored
Merge pull request #20 from 9072997/master
Allow alternate ACME URLs
2 parents 975b5b1 + 160011c commit 2dbabfa

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

hosts.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,8 @@ func watchHostsChanges(filename string, fn func()) error {
7676
watcher.Add(filename)
7777

7878
for {
79-
select {
80-
case <-watcher.Events:
81-
fn()
82-
}
79+
<-watcher.Events
80+
fn()
8381
}
8482
}
8583

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/labstack/echo/v4"
77
"github.com/labstack/echo/v4/middleware"
8+
"golang.org/x/crypto/acme"
89
"golang.org/x/crypto/acme/autocert"
910
)
1011

@@ -13,6 +14,10 @@ func main() {
1314
e.HideBanner = true
1415
e.AutoTLSManager.HostPolicy = autocert.HostWhitelist(getAvailableHosts()...)
1516
e.AutoTLSManager.Cache = autocert.DirCache(*flagAutocertCacheDir)
17+
e.AutoTLSManager.Client = &acme.Client{
18+
DirectoryURL: *flagACMEDirectory,
19+
UserAgent: "https://github.com/alash3al/httpsify",
20+
}
1621

1722
e.Use(middleware.HTTPSRedirect())
1823
e.Use(middleware.Logger())

vars.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"sync/atomic"
77

88
"github.com/mitchellh/go-homedir"
9+
"golang.org/x/crypto/acme/autocert"
910
)
1011

1112
var (
@@ -18,5 +19,6 @@ var (
1819
flagHTTPAddr = flag.String("http", ":80", "the port to listen for http requests on, it is recommended to leave it as is")
1920
flagAutocertCacheDir = flag.String("certs", path.Join(homeDir, ".httpsify/certs"), "the certs directory")
2021
flagHostsFile = flag.String("hosts", path.Join(homeDir, ".httpsify/hosts.json"), "the file containing hosts mappings to upstreams")
22+
flagACMEDirectory = flag.String("acme-directory", autocert.DefaultACMEDirectory, "the server to request certificates from")
2123
flagSendXSecuredBy = flag.Bool("x-secured-by", true, "whether to enable x-secured-by header or not")
2224
)

0 commit comments

Comments
 (0)