go-proxy/main.go
2019-06-18 04:22:31 +02:00

20 lines
339 B
Go

package main
import (
"fmt"
"log"
"net/http"
"net/http/httputil"
"net/url"
"os"
)
func main() {
url, err := url.Parse(fmt.Sprintf("http://%s", os.Getenv("DESTINATION_ADDR")))
if err != nil {
log.Fatal(err)
}
proxy := httputil.NewSingleHostReverseProxy(url)
log.Fatal(http.ListenAndServe(os.Getenv("SOURCE_ADDR"), proxy))
}