code: func redirPlaintextHost(cfg *SiteConfig) *SiteConfig {
  	redirPort := cfg.Addr.Port
  	if redirPort == "443" {
  		// default port is redundant
  		redirPort = ""
  	}
  	redirMiddleware := func(next Handler) Handler {
  		return HandlerFunc(func(w http.ResponseWriter, r *http.Request) (int, error) {
  			toURL := "https://" + r.Host
  			if redirPort != "" {
  				toURL += ":" + redirPort
  			}
  			toURL += r.URL.RequestURI()
  			w.Header().Set("Connection", "close")
  			http.Redirect(w, r, toURL, http.StatusMovedPermanently)
  			return 0, nil
  		})
  	}
  	host := cfg.Addr.Host
  	port := "80"
  	addr := net.JoinHostPort(host, port)
  	return &SiteConfig{
  		Addr:       Address{Original: addr, Host: host, Port: port},
  		ListenHost: cfg.ListenHost,
  		middleware: []Middleware{redirMiddleware},
  		TLS:        &caddytls.Config{AltHTTPPort: cfg.TLS.AltHTTPPort},
  	}
  }
docs: // redirPlaintextHost returns a new plaintext HTTP configuration for
  // a virtualHost that simply redirects to cfg, which is assumed to
  // be the HTTPS configuration. The returned configuration is set
  // to listen on port 80. The TLS field of cfg must not be nil.