关于golang代码库的HTTPS/HTTP概念问题

huangapple go评论79阅读模式
英文:

Conceptual HTTPS/HTTP question for golang repository

问题

我有一个使用Golang构建的Gateway API。我们使用了“net/http”库,文档在这里https://pkg.go.dev/net/http#example-ListenAndServeTLS。该服务已经设置了HTTPS连接。我使用TLS终止,所以与我的ELB的连接使用HTTPS。因此,这个Gateway API有SSL证书。但是,它将连接传递给其他实例时,使用的是普通的HTTP连接。

简而言之,Gateway API支持HTTPS,但连接到Gateway API的服务使用的是HTTP。

当我检查我的UI服务时,显示我们仍在使用HTTP 1.1。然而,根据Golang的文档,包“net/http”应该自动提供HTTP 2.0支持。

我是否需要升级我的内部服务,以使用HTTPS而不是HTTP,以便使用HTTP 2.0?

如果这篇文章显得无知或粗鲁,我很抱歉。我非常感谢任何花时间阅读这篇文章的人,并愿意提供任何需要的更多信息。

英文:

I have a Gateway API that is built with Golang. We use the "net/http" library documented here https://pkg.go.dev/net/http#example-ListenAndServeTLS. This service has HTTPS connection set up. The connections to my ELB’s use HTTPS because I use TLS termination. So this one Gateway API has the ssl cert. But then passes the connection to a regular HTTP connection to the other instances.

In short, the Gateway API has HTTPs support, but the services connected to my Gateway API uses HTTP.

When I check my UI services, It shows that we are using HTTP 1.1 still. However from Golang's documentation the package "net/http" should provide HTTP 2.0 support automatically.

Do I need to upgrade my internal services to use HTTPs instead of HTTP in order to use http 2.0?

Sorry If this post comes off as ignorant or rude. I really appreciate anyone taking there time to read this, and am willing to provide any more information that Is needed.

答案1

得分: 1

http2包括h2(使用TLS)和h2c(不使用TLS),net/http在使用ListenAndServeTLS时默认使用h2。

如果你使用http,net/http不会使用h2c,而是使用http1.1。目前没有浏览器支持未加密的HTTP/2

因为net/http默认不支持h2c,如果你想使用h2c(非TLS版本的HTTP/2):

https://pkg.go.dev/golang.org/x/net@v0.0.0-20220421235706-1d1ef9303861/http2/h2c

英文:

http2 include h2(TLS) h2c(no TLS), net/http use h2 default when ListenAndServeTLS.

if you use http, net/http not use h2c, but http1.1 currently no browser supports HTTP/2 unencrypted

becase net/http don't support h2c default, if you want use h2c(non-TLS version of HTTP/2):

https://pkg.go.dev/golang.org/x/net@v0.0.0-20220421235706-1d1ef9303861/http2/h2c

huangapple
  • 本文由 发表于 2022年4月22日 05:41:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/71961183.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定