Skip to content

Commit

Permalink
Add support for HTTP-01 ACME challenges
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinmcconnell committed Sep 30, 2024
1 parent 397b839 commit bd188f2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions internal/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,20 @@ func (s *Service) createCertManager() *autocert.Manager {
}

func (s *Service) createMiddleware() http.Handler {
var handler http.Handler = http.HandlerFunc(s.serviceRequestWithTarget)

if s.options.ErrorPagePath != "" {
slog.Debug("Using custom error pages", "service", s.name, "path", s.options.ErrorPagePath)
errorPageFS := os.DirFS(s.options.ErrorPagePath)
return WithErrorPageMiddleware(errorPageFS, false, http.HandlerFunc(s.serviceRequestWithTarget))
handler = WithErrorPageMiddleware(errorPageFS, false, handler)
}

if s.certManager != nil {
slog.Debug("Using ACME handler", "service", s.name)
handler = s.certManager.HTTPHandler(handler)
}

return http.HandlerFunc(s.serviceRequestWithTarget)
return handler
}

func (s *Service) serviceRequestWithTarget(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit bd188f2

Please sign in to comment.