mirror of
https://github.com/tobychui/zoraxy.git
synced 2025-11-12 03:44:04 +01:00
@@ -6,6 +6,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@@ -301,6 +302,29 @@ func (p *ReverseProxy) ProxyHTTP(rw http.ResponseWriter, req *http.Request, rrr
|
|||||||
return http.StatusBadGateway, err
|
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.
|
// Remove hop-by-hop headers listed in the "Connection" header of the response, Remove hop-by-hop headers.
|
||||||
if !rrr.NoRemoveHopByHop {
|
if !rrr.NoRemoveHopByHop {
|
||||||
removeHeaders(res.Header, rrr.NoCache)
|
removeHeaders(res.Header, rrr.NoCache)
|
||||||
|
|||||||
Reference in New Issue
Block a user