httputilのReverseProxyを使う Go言語でリバースプロキシを立てるには、httputilパッケージにあるReverseProxyを使うと簡単。 ReverseProxyはhttp.Handlerインタフェースを実装していて、http.ServerのHandlerに渡せる。 以下はlocalhost:9000のリクエストをlocalhost:9001に移譲する処理。 package main import ( "log" "net/http" "net/http/httputil" ) func main() { director := func(request *http.Request) { request.URL.Scheme = "http" request.URL.Host = ":9001" } rp := &httputil.ReverseProxy{Dire

