get acme-challenges over https too
This commit is contained in:
parent
ebce63c08e
commit
e63b99d49b
|
@ -33,21 +33,23 @@ func RouteStatic(r chi.Router) chi.Router {
|
||||||
r.Use(middleware.Timeout(15 * time.Second))
|
r.Use(middleware.Timeout(15 * time.Second))
|
||||||
r.Use(middleware.Recoverer)
|
r.Use(middleware.Recoverer)
|
||||||
|
|
||||||
r.Get("/.well-known/acme-challenge/{token}", func(w http.ResponseWriter, r *http.Request) {
|
r.Get("/.well-known/acme-challenge/{token}", getACMEChallenges)
|
||||||
//token := chi.URLParam(r, "token")
|
|
||||||
host := r.Host
|
|
||||||
if strings.ContainsAny(host, "/:|\\") {
|
|
||||||
host = ""
|
|
||||||
}
|
|
||||||
tokenPath := filepath.Join(tmpBase, host)
|
|
||||||
|
|
||||||
fsrv := http.FileServer(http.Dir(tokenPath))
|
|
||||||
fsrv.ServeHTTP(w, r)
|
|
||||||
})
|
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getACMEChallenges(w http.ResponseWriter, r *http.Request) {
|
||||||
|
//token := chi.URLParam(r, "token")
|
||||||
|
host := r.Host
|
||||||
|
if strings.ContainsAny(host, "/:|\\") {
|
||||||
|
host = ""
|
||||||
|
}
|
||||||
|
tokenPath := filepath.Join(tmpBase, host)
|
||||||
|
|
||||||
|
fsrv := http.FileServer(http.Dir(tokenPath))
|
||||||
|
fsrv.ServeHTTP(w, r)
|
||||||
|
}
|
||||||
|
|
||||||
func RouteAll() chi.Router {
|
func RouteAll() chi.Router {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -74,6 +76,8 @@ func RouteAll() chi.Router {
|
||||||
r.Use(middleware.Timeout(15 * time.Second))
|
r.Use(middleware.Timeout(15 * time.Second))
|
||||||
r.Use(middleware.Recoverer)
|
r.Use(middleware.Recoverer)
|
||||||
|
|
||||||
|
r.Get("/.well-known/acme-challenge/{token}", getACMEChallenges)
|
||||||
|
|
||||||
r.Route("/api", func(r chi.Router) {
|
r.Route("/api", func(r chi.Router) {
|
||||||
r.Use(func(next http.Handler) http.Handler {
|
r.Use(func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
Loading…
Reference in New Issue