Skip to content

Enable HTTP/2 on internal TLS listeners - #29

Merged
SanjeevLakhwani merged 2 commits into
mainfrom
feat/enable-http2
Sep 24, 2026
Merged

SanjeevLakhwani merged 2 commits into
mainfrom
feat/enable-http2

Conversation

@SanjeevLakhwani

@SanjeevLakhwani SanjeevLakhwani commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Adds http2 on; to public, protal, and the domain-redirect server blocks. (OpenResty 1.31.1.1 is already compiled with --with-http_v2_module and ALPN/TLS 1.3 config was already in place)
  • Fixes a regression exposed by enabling HTTP/2: browsers now multiplex dozens of _next/static/ chunk requests over a single connection instead of trickling them through HTTP/1.1's 6-connection cap, which blew past the limit_req zone=perip burst=30; rate limit in proxy.conf and caused a wave of 503s / ChunkLoadErrors on initial page load. Fixed by splitting proxy.conf's reverse-proxy directives into a shared proxy_common.conf, and adding a /_next/static/, /__nextjs_ and /public/ location that proxies through proxy_common.conf with a separate, looser rate limit (static_perip, 75r/s, burst=200), while dynamic/API traffic through location / keeps the existing protection unchanged.

TLS is terminated on the internal 444 listeners (port 443 is just an
SNI-sniffing passthrough in the stream block), so http2 on; belongs
there. OpenResty 1.31.1.1 is already compiled with
--with-http_v2_module and ALPN/TLS 1.3 config is already in place, so
this is the only directive needed to stop connections falling back to
http/1.1 and queueing requests in batches of 6.
@SanjeevLakhwani
SanjeevLakhwani force-pushed the feat/enable-http2 branch 2 times, most recently from e1dc435 to 66f27e6 Compare September 22, 2026 15:24
@SanjeevLakhwani
SanjeevLakhwani force-pushed the feat/enable-http2 branch 2 times, most recently from d460f92 to 8ddd330 Compare September 22, 2026 15:56

@v-rocheleau v-rocheleau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!
Some suggestions and a question.

Leaving the final approval to David since I'm a total NextJS noob 😅

Comment thread conf/nginx.conf.tpl Outdated
Comment thread conf/nginx.conf.tpl Outdated
Comment thread conf/nginx.conf.tpl
@SanjeevLakhwani
SanjeevLakhwani force-pushed the feat/enable-http2 branch 2 times, most recently from cf340dd to 5e56ac5 Compare September 23, 2026 14:52
Comment thread conf/nginx.conf.tpl Outdated
Comment thread conf/proxy_common.conf
Comment thread conf/nginx.conf.tpl Outdated
HTTP/2 lets the browser fire dozens of _next/static chunk requests on
one connection instead of trickling them through 6 HTTP/1.1
connections, which tripped the perip limit_req (rate=10r/s, burst=30)
in proxy.conf and caused a wave of 503s / ChunkLoadErrors on initial
page load for Bento Public (confirmed via bentov2_public_errors.log:
"limiting requests ... by zone perip").

Split proxy.conf's non-rate-limit directives into proxy_common.conf and
proxy /_next/static/, /public/ (plus Next.js dev-mode /__nextjs_
helpers) through a separate, looser static_perip zone (75r/s,
burst=200) so page-load bursts pass while dynamic/API traffic through
location / keeps the existing limits.

@davidlougheed davidlougheed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, faster on my laptop

@SanjeevLakhwani
SanjeevLakhwani merged commit 27e3035 into main Sep 24, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants