golang http1.1的请求负载均衡按照http2.0转发问题
Posted 刘斌Brian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了golang http1.1的请求负载均衡按照http2.0转发问题相关的知识,希望对你有一定的参考价值。
关键参数:
TLSNextProto
解决方案:
把TLSNextProto设置成空map,这样就不会自动升级,相当于关闭http2.0
client := &http.Client {
Transport:&http.Transport{
TLSNextProto: map[string]func(authority string, c *tls.Conn) http.RoundTripper{},
},
}
原因:
来自 https://stackoverflow.com/que...
Starting with Go 1.6, the http package has transparent support for the HTTP/2 protocol when using HTTPS. Programs that must disable HTTP/2 can do so by setting Transport.TLSNextProto (for clients) or Server.TLSNextProto (for servers) to a non-nil, empty map. Alternatively, the following GODEBUG environment variables are currently supported:
以上是关于golang http1.1的请求负载均衡按照http2.0转发问题的主要内容,如果未能解决你的问题,请参考以下文章