Hi,
Am using "net/http/httputil" Reverse proxy and would to make HTTPS
forwarding between the two proxy servers. Any help on how to handle HTTPS
between the proxy servers instead of HTTP?
Here are a sample of my code.
Proxy A
func main() {
http.HandleFunc("/", proxyPassA)
server.ListenAndServeTLS(certFile, keyFile)
}
func proxyPassA(res http.ResponseWriter, req *http.Request) {
server := NewServer("127.0.0.1:8080")
ServerB := http://127.0.0.1:10010
url, _ := url.Parse(ServerB)
proxy := httputil.NewSingleHostReverseProxy(url)
proxy.ServeHTTP(res, req)
}
// NewServer - Create a new server
func NewServer(addr string) *http.Server {
return &http.Server{
Addr: addr,
TLSConfig: tLSConfig(),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
}
}
Proxy B
func main() {
http.HandleFunc("/", proxyPassB)
server.ListenAndServeTLS(certFile, keyFile)
}
func proxyPassA(res http.ResponseWriter, req *http.Request) {
server := NewServer("127.0.0.1:7070")
remotehttpserver := http://127.0.0.1:6001
url, _ := url.Parse(remotehttpserver)
proxy := httputil.NewSingleHostReverseProxy(url)
proxy.ServeHTTP(res, req)
}
// NewServer - Create a new server
func NewServer(addr string) *http.Server {
return &http.Server{
Addr: addr,
TLSConfig: tLSConfig(),
ReadTimeout: 5 * time.Second,
WriteTimeout: 10 * time.Second,
IdleTimeout: 120 * time.Second,
}
}
BR
Fury
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/golang-nuts/b2fd430a-30f6-4a0e-b735-d7455343ae36n%40googlegroups.com.