MCPcopy
hub / github.com/caddyserver/caddy / makeRedirRoute

Method makeRedirRoute

modules/caddyhttp/autohttps.go:544–575  ·  view source on GitHub ↗
(redirToPort uint, matcherSet MatcherSet)

Source from the content-addressed store, hash-verified

542}
543
544func (app *App) makeRedirRoute(redirToPort uint, matcherSet MatcherSet) Route {
545 redirTo := "https://{http.request.host}"
546
547 // since this is an external redirect, we should only append an explicit
548 // port if we know it is not the officially standardized HTTPS port, and,
549 // notably, also not the port that Caddy thinks is the HTTPS port (the
550 // configurable HTTPSPort parameter) - we can't change the standard HTTPS
551 // port externally, so that config parameter is for internal use only;
552 // we also do not append the port if it happens to be the HTTP port as
553 // well, obviously (for example, user defines the HTTP port explicitly
554 // in the list of listen addresses for a server)
555 if redirToPort != uint(app.httpPort()) &&
556 redirToPort != uint(app.httpsPort()) &&
557 redirToPort != DefaultHTTPPort &&
558 redirToPort != DefaultHTTPSPort {
559 redirTo += ":" + strconv.Itoa(int(redirToPort))
560 }
561
562 redirTo += "{http.request.uri}"
563 return Route{
564 MatcherSets: []MatcherSet{matcherSet},
565 Handlers: []MiddlewareHandler{
566 StaticResponse{
567 StatusCode: WeakString(strconv.Itoa(http.StatusPermanentRedirect)),
568 Headers: http.Header{
569 "Location": []string{redirTo},
570 },
571 Close: true,
572 },
573 },
574 }
575}
576
577func httpsRRALPNs(srv *Server) []string {
578 alpn := make(map[string]struct{}, 3)

Callers 1

automaticHTTPSPhase1Method · 0.95

Implementers 6

fooModuleadmin_test.go
PKImodules/caddypki/pki.go
TLSmodules/caddytls/tls.go
Filesystemsmodules/caddyfs/filesystem.go
Appmodules/caddyhttp/app.go
Appmodules/caddyevents/app.go

Calls 3

httpPortMethod · 0.95
httpsPortMethod · 0.95
WeakStringTypeAlias · 0.85

Tested by

no test coverage detected