Skip to content

Commit

Permalink
Use h2c from x/net to handle h2c requests
Browse files Browse the repository at this point in the history
Co-authored-by: Mathieu Lonjaret <[email protected]>
  • Loading branch information
2 people authored and traefiker committed Jul 1, 2019
1 parent c7d336f commit 4360ca1
Show file tree
Hide file tree
Showing 224 changed files with 22,312 additions and 11,666 deletions.
8 changes: 4 additions & 4 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 11 additions & 13 deletions pkg/server/server_entrypoint_tcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ import (

"github.com/armon/go-proxyproto"
"github.com/containous/traefik/pkg/config/static"
"github.com/containous/traefik/pkg/h2c"
"github.com/containous/traefik/pkg/ip"
"github.com/containous/traefik/pkg/log"
"github.com/containous/traefik/pkg/middlewares"
"github.com/containous/traefik/pkg/middlewares/forwardedheaders"
"github.com/containous/traefik/pkg/safe"
"github.com/containous/traefik/pkg/tcp"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)

type httpForwarder struct {
Expand Down Expand Up @@ -336,26 +337,23 @@ type httpServer struct {

func createHTTPServer(ln net.Listener, configuration *static.EntryPoint, withH2c bool) (*httpServer, error) {
httpSwitcher := middlewares.NewHandlerSwitcher(buildDefaultHTTPRouter())
handler, err := forwardedheaders.NewXForwarded(

var handler http.Handler
var err error
handler, err = forwardedheaders.NewXForwarded(
configuration.ForwardedHeaders.Insecure,
configuration.ForwardedHeaders.TrustedIPs,
httpSwitcher)
if err != nil {
return nil, err
}

var serverHTTP stoppableServer

if withH2c {
serverHTTP = &h2c.Server{
Server: &http.Server{
Handler: handler,
},
}
} else {
serverHTTP = &http.Server{
Handler: handler,
}
handler = h2c.NewHandler(handler, &http2.Server{})
}

serverHTTP := &http.Server{
Handler: handler,
}

listener := newHTTPForwarder(ln)
Expand Down
24 changes: 14 additions & 10 deletions vendor/golang.org/x/net/bpf/constants.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4360ca1

Please sign in to comment.