Created
June 29, 2017 05:36
-
-
Save dselans/c979004e86ebfecac170fe8501fb8d65 to your computer and use it in GitHub Desktop.
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
// example reverse proxy | |
package main | |
import ( | |
"fmt" | |
"log" | |
"net/http" | |
"net/http/httputil" | |
) | |
func main() { | |
log.Fatal(http.ListenAndServe(":8181", &httputil.ReverseProxy{ | |
Director: func(r *http.Request) { | |
fmt.Printf("Proxying request for '%v' from: %v\n", r.URL.Path, r.RemoteAddr) | |
r.URL.Scheme = "http" | |
r.Host = "httpbin.org" | |
r.URL.Host = "httpbin.org:80" | |
}, | |
})) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment