Skip to content

Instantly share code, notes, and snippets.

@dselans
Created June 29, 2017 05:36
Show Gist options
  • Save dselans/c979004e86ebfecac170fe8501fb8d65 to your computer and use it in GitHub Desktop.
Save dselans/c979004e86ebfecac170fe8501fb8d65 to your computer and use it in GitHub Desktop.
// 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