Example #1
0
func main() {
	flag.Parse()
	goquic.SetLogLevel(logLevel)

	if flag.NArg() != 1 {
		flag.Usage()
		return
	}

	proxyUrl := flag.Arg(0)

	log.Printf("About to listen on %d. Go to https://127.0.0.1:%d/", port, port)
	portStr := fmt.Sprintf(":%d", port)

	parsedUrl, err := url.Parse(proxyUrl)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Starting reverse proxy for backend URL: %v", parsedUrl)

	err = goquic.ListenAndServe(portStr, cert, key, numOfServers, httputil.NewSingleHostReverseProxy(parsedUrl))
	if err != nil {
		log.Fatal(err)
	}
}
Example #2
0
func main() {
	flag.Parse()
	goquic.SetLogLevel(logLevel)

	useEncryption := false
	if len(cert) > 0 && len(key) > 0 {
		useEncryption = true
	}

	scheme := "http"
	if useEncryption {
		scheme = "https"
	}
	log.Printf("About to listen on %d. Go to %s://127.0.0.1:%d/", port, scheme, port)
	portStr := fmt.Sprintf(":%d", port)

	http.HandleFunc("/", httpHandler)
	http.Handle("/files/", http.StripPrefix("/files/", http.FileServer(http.Dir(serveRoot))))

	var err error

	if useEncryption {
		err = goquic.ListenAndServeSecure(portStr, cert, key, numOfServers, nil)
	} else {
		err = goquic.ListenAndServe(portStr, numOfServers, nil)
	}

	if err != nil {
		log.Fatal(err)
	}
}
Example #3
0
func main() {
	flag.Parse()
	goquic.SetLogLevel(logLevel)

	if flag.NArg() != 1 {
		flag.Usage()
		return
	}

	useEncryption := false
	if len(cert) > 0 && len(key) > 0 {
		useEncryption = true
	}
	proxyUrl := flag.Arg(0)

	scheme := "http"
	if useEncryption {
		scheme = "https"
	}
	log.Printf("About to listen on %d. Go to %s://127.0.0.1:%d/", port, scheme, port)
	portStr := fmt.Sprintf(":%d", port)

	parsedUrl, err := url.Parse(proxyUrl)
	if err != nil {
		log.Fatal(err)
	}

	log.Printf("Starting reverse proxy for backend URL: %v", parsedUrl)

	if useEncryption {
		err = goquic.ListenAndServeSecure(portStr, cert, key, numOfServers, httputil.NewSingleHostReverseProxy(parsedUrl))
	} else {
		err = goquic.ListenAndServe(portStr, numOfServers, httputil.NewSingleHostReverseProxy(parsedUrl))
	}
	if err != nil {
		log.Fatal(err)
	}
}