Skip to content

Commit

Permalink
accept both HTTP and HTTPS traffic
Browse files Browse the repository at this point in the history
  • Loading branch information
did committed Nov 29, 2024
1 parent f91ed90 commit 511ea98
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/cmd/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func newDeployCommand() *deployCommand {

deployCommand.cmd.Flags().BoolVar(&deployCommand.args.ServiceOptions.TLSEnabled, "tls", false, "Configure TLS for this target (requires a non-empty host)")
deployCommand.cmd.Flags().StringVar(&deployCommand.args.ServiceOptions.TLSOnDemandUrl, "tls-on-demand-url", "", "Will make an HTTP request to the given URL, asking whether a host is allowed to have a certificate issued.")
deployCommand.cmd.Flags().BoolVar(&deployCommand.args.ServiceOptions.TLSFlexibleMode, "tls-flexible-mode", false, "Allow Kamal proxy to be flexible (accept both HTTP and HTTPS traffic)")
deployCommand.cmd.Flags().BoolVar(&deployCommand.tlsStaging, "tls-staging", false, "Use Let's Encrypt staging environment for certificate provisioning")
deployCommand.cmd.Flags().StringVar(&deployCommand.args.ServiceOptions.TLSCertificatePath, "tls-certificate-path", "", "Configure custom TLS certificate path (PEM format)")
deployCommand.cmd.Flags().StringVar(&deployCommand.args.ServiceOptions.TLSPrivateKeyPath, "tls-private-key-path", "", "Configure custom TLS private key path (PEM format)")
Expand Down
3 changes: 2 additions & 1 deletion internal/server/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ type ServiceOptions struct {
TLSOnDemandUrl string `json:"tls_on_demand_url"`
TLSCertificatePath string `json:"tls_certificate_path"`
TLSPrivateKeyPath string `json:"tls_private_key_path"`
TLSFlexibleMode bool `json:"tls_flexible_mode"`
ACMEDirectory string `json:"acme_directory"`
ACMECachePath string `json:"acme_cache_path"`
ErrorPagePath string `json:"error_page_path"`
Expand Down Expand Up @@ -391,7 +392,7 @@ func (s *Service) createMiddleware(options ServiceOptions, certManager CertManag
func (s *Service) serviceRequestWithTarget(w http.ResponseWriter, r *http.Request) {
LoggingRequestContext(r).Service = s.name

if s.options.TLSEnabled && r.TLS == nil {
if s.options.TLSEnabled && s.options.TLSFlexibleMode == false && r.TLS == nil {
s.redirectToHTTPS(w, r)
return
}
Expand Down

0 comments on commit 511ea98

Please sign in to comment.