mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
lib/proxy: pass proxy hostname in Host
header of the CONNECT
request
This should resolve the following issue when connecting to tls proxy: cannot validate certificate for ... because it doesn't contain any IP SANs
This commit is contained in:
parent
9d8223eafb
commit
e15f3f4f2a
1 changed files with 3 additions and 3 deletions
|
@ -86,7 +86,7 @@ func (u *URL) NewDialFunc(ac *promauth.Config) (fasthttp.DialFunc, error) {
|
||||||
}
|
}
|
||||||
proxyConn = tls.Client(proxyConn, tlsCfgLocal)
|
proxyConn = tls.Client(proxyConn, tlsCfgLocal)
|
||||||
}
|
}
|
||||||
conn, err := sendConnectRequest(proxyConn, addr, authHeader)
|
conn, err := sendConnectRequest(proxyConn, proxyAddr, addr, authHeader)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = proxyConn.Close()
|
_ = proxyConn.Close()
|
||||||
return nil, fmt.Errorf("error when sending CONNECT request to proxy %q: %w", pu, err)
|
return nil, fmt.Errorf("error when sending CONNECT request to proxy %q: %w", pu, err)
|
||||||
|
@ -125,8 +125,8 @@ func defaultDialFunc(addr string) (net.Conn, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sendConnectRequest sends CONNECT request to proxyConn for the given addr and authHeader and returns the established connection to dstAddr.
|
// sendConnectRequest sends CONNECT request to proxyConn for the given addr and authHeader and returns the established connection to dstAddr.
|
||||||
func sendConnectRequest(proxyConn net.Conn, dstAddr, authHeader string) (net.Conn, error) {
|
func sendConnectRequest(proxyConn net.Conn, proxyAddr, dstAddr, authHeader string) (net.Conn, error) {
|
||||||
req := "CONNECT " + dstAddr + " HTTP/1.1\r\nHost: " + dstAddr + "\r\n" + authHeader + "\r\n"
|
req := "CONNECT " + dstAddr + " HTTP/1.1\r\nHost: " + proxyAddr + "\r\n" + authHeader + "\r\n"
|
||||||
if _, err := proxyConn.Write([]byte(req)); err != nil {
|
if _, err := proxyConn.Write([]byte(req)); err != nil {
|
||||||
return nil, fmt.Errorf("cannot send CONNECT request for dstAddr=%q: %w", dstAddr, err)
|
return nil, fmt.Errorf("cannot send CONNECT request for dstAddr=%q: %w", dstAddr, err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue