Explain how reverse proxy work

Hey @drafdev,

There are a few answers I’ve found that you can read into to do this if you’d like:


or

But in the meantime, you can get your reverse proxy working with https with as little code as this, but I would actually read those posted answers if I was you :slight_smile:

package main

import (
	"log"
	"net/http"
	"net/http/httputil"
	"net/url"
)

type Transport struct{}

func (t *Transport) RoundTrip(req *http.Request) (*http.Response, error) {
	req.Host = req.URL.Host
	return http.DefaultTransport.RoundTrip(req)
}

func main() {
	rp := httputil.NewSingleHostReverseProxy(&url.URL{
		Scheme: "https",
		Host:   "httpbin.org",
	})
	rp.Transport = &Transport{}

	http.Handle("/", rp)
	log.Fatal(http.ListenAndServe(":8080", nil))
}