Created
February 1, 2021 05:26
-
-
Save rxda/a8e39e6227f4c0baab26e084e6c505ab to your computer and use it in GitHub Desktop.
Golang ReverseProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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