Skip to content

Instantly share code, notes, and snippets.

@olostan
Created December 1, 2016 12:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olostan/cee61b76dd426de392f6df2d372aa9e8 to your computer and use it in GitHub Desktop.
Save olostan/cee61b76dd426de392f6df2d372aa9e8 to your computer and use it in GitHub Desktop.
package main
import (
"log"
"net/http"
"net/http/httputil"
"fmt"
)
type proxyHandler struct {
binding string
}
func (p *proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
director := func(req *http.Request) {
req = r
req.URL.Scheme = "http"
req.URL.Host = "10.20.20.116"+p.binding
}
proxy := &httputil.ReverseProxy{Director: director}
proxy.ServeHTTP(w, r)
}
func main() {
runner := func(binding string) {
fmt.Printf("Listening on %s\n", binding);
log.Fatal(http.ListenAndServe(binding, &proxyHandler{binding}));
};
go runner(":8180");
go runner(":80");
select{}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment