go-proxy/main.go

21 lines
339 B
Go
Raw Permalink Normal View History

2019-06-18 01:05:06 +00:00
package main
import (
2019-06-18 02:22:31 +00:00
"fmt"
2019-06-18 01:05:06 +00:00
"log"
2019-06-18 02:22:31 +00:00
"net/http"
"net/http/httputil"
"net/url"
2019-06-18 01:05:06 +00:00
"os"
)
func main() {
2019-06-18 02:22:31 +00:00
url, err := url.Parse(fmt.Sprintf("http://%s", os.Getenv("DESTINATION_ADDR")))
if err != nil {
log.Fatal(err)
2019-06-18 01:05:06 +00:00
}
2019-06-18 02:22:31 +00:00
proxy := httputil.NewSingleHostReverseProxy(url)
log.Fatal(http.ListenAndServe(os.Getenv("SOURCE_ADDR"), proxy))
2019-06-18 01:05:06 +00:00
}