Skip to content

Instantly share code, notes, and snippets.

@rxda
Created February 1, 2021 05:26
Show Gist options
  • Save rxda/a8e39e6227f4c0baab26e084e6c505ab to your computer and use it in GitHub Desktop.
Save rxda/a8e39e6227f4c0baab26e084e6c505ab to your computer and use it in GitHub Desktop.
Golang ReverseProxy
func main() {
u := &url.URL{
Scheme: "http",
Host: "intelliep-api.rocktl.com",
}
proxy := httputil.NewSingleHostReverseProxy(u)
proxy.Director = func(r *http.Request) {
r.Host = "intelliep-api.rocktl.com"
r.URL.Host = r.Host
r.URL.Scheme = "http"
}
http.Handle("/", proxy)
http.ListenAndServe(":8080", nil)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment