Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/2.8] feat: Add HTTP2 for unencrypted HTTP (v2) #4246

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 6 additions & 0 deletions configuration/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,12 @@ type Configuration struct {
// to connect via http2. If set to true, only http/1.1 is supported.
Disabled bool `yaml:"disabled,omitempty"`
} `yaml:"http2,omitempty"`

H2C struct {
// Enables H2C (unencrypted HTTP2). Enable to support HTTP2 without needing to configure TLS
// Useful when deploying the registry behind a load balancer (e.g. Cloud Run)
Enabled bool `yaml:"enabled,omitempty"`
} `yaml:"h2c,omitempty"`
} `yaml:"http,omitempty"`

// Notifications specifies configuration about various endpoint to which
Expand Down
8 changes: 8 additions & 0 deletions configuration/configuration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ var configStruct = Configuration{
HTTP2 struct {
Disabled bool `yaml:"disabled,omitempty"`
} `yaml:"http2,omitempty"`
H2C struct {
Enabled bool `yaml:"enabled,omitempty"`
} `yaml:"h2c,omitempty"`
}{
TLS: struct {
Certificate string `yaml:"certificate,omitempty"`
Expand All @@ -128,6 +131,11 @@ var configStruct = Configuration{
}{
Disabled: false,
},
H2C: struct {
Enabled bool `yaml:"enabled,omitempty"`
}{
Enabled: true,
},
},
}

Expand Down
10 changes: 9 additions & 1 deletion registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ import (

"rsc.io/letsencrypt"

"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"

logrus_bugsnag "github.com/Shopify/logrus-bugsnag"

logstash "github.com/bshuster-repo/logrus-logstash-hook"
Expand Down Expand Up @@ -170,8 +173,13 @@ func NewRegistry(ctx context.Context, config *configuration.Configuration) (*Reg
handler = gorhandlers.CombinedLoggingHandler(os.Stdout, handler)
}

httpHandler := handler
if config.HTTP.H2C.Enabled {
httpHandler = h2c.NewHandler(handler, &http2.Server{})
}

server := &http.Server{
Handler: handler,
Handler: httpHandler,
}

return &Registry{
Expand Down
4 changes: 2 additions & 2 deletions vendor.conf
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ github.com/yvasiyarov/go-metrics 57bccd1ccd43f94bb17fdd8bf3007059b802f85e
github.com/yvasiyarov/gorelic a9bba5b9ab508a086f9a12b8c51fab68478e2128
github.com/yvasiyarov/newrelic_platform_go b21fdbd4370f3717f3bbd2bf41c223bc273068e6
golang.org/x/crypto c10c31b5e94b6f7a0283272dc2bb27163dcea24b
golang.org/x/net b225e7ca6dde1ef5a5ae5ce922861bda011cfabd # v0.17.0
golang.org/x/text f488e191e67ed95a5b9b7b39024e5a5f5f1ffd02 # v0.13.0
golang.org/x/net a8e0109124268a0a063b5900bce0c2b33398ec01 # v0.19.0
golang.org/x/text 6c97a165dd661335ff7bce6104a008558123c353 # v0.14.0
golang.org/x/oauth2 045497edb6234273d67dbc25da3f2ddbc4c4cacf
golang.org/x/time a4bde12657593d5e90d0533a3e4fd95e635124cb
google.golang.org/api 9bf6e6e569ff057f75d9604a46c52928f17d2b54
Expand Down
10 changes: 10 additions & 0 deletions vendor/golang.org/x/net/.gitattributes

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

2 changes: 2 additions & 0 deletions vendor/golang.org/x/net/.gitignore

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

26 changes: 26 additions & 0 deletions vendor/golang.org/x/net/CONTRIBUTING.md

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

41 changes: 41 additions & 0 deletions vendor/golang.org/x/net/bpf/asm.go

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

222 changes: 222 additions & 0 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.