mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-10-15 07:09:36 +02:00
@@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strings"
|
||||
@@ -301,6 +302,29 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
||||
return http.StatusBadGateway, err
|
||||
}
|
||||
|
||||
//Fix for issue #821
|
||||
if outreq.URL != nil && strings.EqualFold(outreq.URL.Scheme, "https") {
|
||||
if tr, ok := transport.(*http.Transport); ok {
|
||||
serverName := outreq.Host
|
||||
if h, _, err := net.SplitHostPort(serverName); err == nil {
|
||||
serverName = h
|
||||
}
|
||||
|
||||
if tr.TLSClientConfig == nil || tr.TLSClientConfig.ServerName != serverName {
|
||||
trc := tr.Clone()
|
||||
var cfg *tls.Config
|
||||
if tr.TLSClientConfig != nil {
|
||||
cfg = tr.TLSClientConfig.Clone()
|
||||
} else {
|
||||
cfg = &tls.Config{}
|
||||
}
|
||||
cfg.ServerName = serverName
|
||||
trc.TLSClientConfig = cfg
|
||||
transport = trc
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove hop-by-hop headers listed in the "Connection" header of the response, Remove hop-by-hop headers.
|
||||
if !rrr.NoRemoveHopByHop {
|
||||
removeHeaders(res.Header, rrr.NoCache)
|
||||
|
Reference in New Issue
Block a user