hashicorp / nomad

Nomad is an easy-to-use, flexible, and performant workload orchestrator that can deploy a mix of microservice, batch, containerized, and non-containerized applications. Nomad is easy to operate and scale and has native Consul and Vault integrations.
https://www.nomadproject.io/
Other
14.87k stars 1.95k forks source link

Support H2C (http2 over plaintext) in nomad api server #19212

Open thefallentree opened 10 months ago

thefallentree commented 10 months ago

Proposal

enable H2C support on Nomad api server , so when we access API behind a load balancer we can still use HTTP2.

h2s := &http2.Server{}

handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello, %v, http: %v", r.URL.Path, r.TLS == nil)
})

server := &http.Server{
    Addr:    "0.0.0.0:1010",
    Handler: h2c.NewHandler(handler, h2s),
}

fmt.Printf("Listening [0.0.0.0:1010]...\n")
checkErr(server.ListenAndServe(), "while listening")

use following code example, and will make nomad API port support http1, http2, h2c upgrade, h2c pri knowledge all automatically ,regardless if TLS is enabled.

Use-cases

If the access to Nomad API is proxied through a AWS LB, which does the TLS, we can't enable HTTP2 support, which makes the UI super unresponsive because browser only supports 6 connections at same time.

jrasell commented 10 months ago

Hi @thefallentree and thanks for raising this feature request which seems like a sensible idea. I'll mark this for roadmapping and note we might need a little internal discussion and testing to ensure this change to cause any regressions.