https

package
v0.100.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Cmd = &cobra.Command{
	Use:   "https",
	Short: "HTTPS to HTTP Proxy (expose HTTPS, forward to HTTP)",
	Args:  cobra.NoArgs,
	Run: func(c *cobra.Command, args []string) {
		target, err := url.Parse("http://" + CmdFlagRemoteAddr)
		if err != nil {
			log.Fatalf("error: invalid remote address: %s", err)
		}

		proxy := httputil.NewSingleHostReverseProxy(target)

		var tlsCert tls.Certificate
		if CmdFlagCertFile != "" && CmdFlagKeyFile != "" {
			tlsCert, err = tls.LoadX509KeyPair(CmdFlagCertFile, CmdFlagKeyFile)
			if err != nil {
				log.Fatalf("error: failed to load cert/key: %s", err)
			}
		} else {
			tlsCert, err = generateSelfSignedCert()
			if err != nil {
				log.Fatalf("error: failed to generate self-signed cert: %s", err)
			}
			fmt.Println("Using auto-generated self-signed certificate")
		}

		server := &http.Server{
			Addr:    CmdFlagLocalAddr,
			Handler: proxy,
			TLSConfig: &tls.Config{
				Certificates: []tls.Certificate{tlsCert},
			},
		}

		fmt.Printf("Starting HTTPS proxy on %s -> http://%s\n", CmdFlagLocalAddr, CmdFlagRemoteAddr)
		log.Fatal(server.ListenAndServeTLS("", ""))
	},
}
View Source
var CmdFlagCertFile string
View Source
var CmdFlagKeyFile string
View Source
var CmdFlagLocalAddr string
View Source
var CmdFlagRemoteAddr string

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL