Skip to content

Commit

Permalink
Revert "feat: enable h2c for HTTP/2 support on fly.io (#6)" (#7)
Browse files Browse the repository at this point in the history
This reverts commit 121e91f.
  • Loading branch information
mccutchen authored Sep 19, 2024
1 parent 121e91f commit 5a9522a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 44 deletions.
52 changes: 23 additions & 29 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,30 @@ kill_signal = "SIGINT"
kill_timeout = "5s"

[deploy]
strategy = "rolling"
strategy = "rolling"

[env]
PORT = "8080"
PORT = "8080"

[[services]]
protocol = "tcp"
internal_port = 8080

[[services.ports]]
port = 80
handlers = ["http"]

[[services.ports]]
port = 443
handlers = ["tls", "http"]

[[services.tcp_checks]]
interval = "10s"
timeout = "2s"
grace_period = "1s"
restart_limit = 0

[services.concurrency]
type = "connections"
hard_limit = 50
soft_limit = 40

# Enable HTTP/2 support via h2c protocol:
# https://github.com/mccutchen/httpbingo.org/pull/6
# https://community.fly.io/t/support-for-http-trailers/21915
[services.ports.http_options]
h2_backend = true
protocol = "tcp"
internal_port = 8080

[[services.ports]]
port = 80
handlers = ["http"]

[[services.ports]]
port = 443
handlers = ["tls", "http"]

[services.concurrency]
type = "connections"
hard_limit = 50
soft_limit = 40

[[services.tcp_checks]]
interval = "10s"
timeout = "2s"
grace_period = "1s"
restart_limit = 0
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ go 1.22.0
require (
github.com/mccutchen/go-httpbin/v2 v2.15.0
github.com/rs/zerolog v1.33.0
golang.org/x/net v0.29.0
)

require (
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/rs/xid v1.6.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/text v0.18.0 // indirect
)
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,8 @@ github.com/rs/xid v1.6.0 h1:fV591PaemRlL6JfRxGDEPl69wICngIQ3shQtzfy2gxU=
github.com/rs/xid v1.6.0/go.mod h1:7XoLgs4eV+QndskICGsho+ADou8ySMSjJKDIan90Nz0=
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.12.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
9 changes: 0 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import (
"github.com/mccutchen/go-httpbin/v2/httpbin"
"github.com/rs/zerolog"
"github.com/rs/zerolog/hlog"
"golang.org/x/net/http2"
"golang.org/x/net/http2/h2c"
)

const (
Expand Down Expand Up @@ -57,13 +55,6 @@ func main() {
handler = hlog.AccessHandler(requestLogger)(handler)
handler = hlog.NewHandler(logger)(handler)

// fly.io downgrades HTTP/2 connections to HTTP/1.1 by default, but will
// use h2c if explicitly enabled. This should hopefully allow HTTP trailers
// to work w/ HTTP/2 requests. See discussion[1] for a bit more context.
//
// [1]: https://community.fly.io/t/support-for-http-trailers/21915
handler = h2c.NewHandler(handler, &http2.Server{})

srv := &http.Server{
Addr: fmt.Sprintf("0.0.0.0:%s", os.Getenv("PORT")),
Handler: handler,
Expand Down

0 comments on commit 5a9522a

Please sign in to comment.