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{Direc
![go言語でリバースプロキシ | Golang | kido Tech Blog](https://cdn-ak-scissors.b.st-hatena.com/image/square/93413d3a9b60a9516fe1724a88cb9dc24eaffb7d/height=288;version=1;width=512/https%3A%2F%2Fkido0617.github.io%2Fcss%2Fimages%2Fogp.png)