mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-05-14 03:01:48 +00:00
Enable h2c:// (cleartext HTTP/2) protocol on all http:// sockets.
This allows git-pages and Caddy to efficiently use the same connection for many pipelined requests, which I hope will reduce contention when some bot decides to send fifty requests in the same millisecond. This commit also changes built-in Caddy configuration to use HTTP/2 cleartext only when talking to the backend.
This commit is contained in:
@@ -51,7 +51,7 @@ http:// {
|
||||
redir @get https://{host}{uri} 301
|
||||
|
||||
# initial PUT/POST for a new domain has to happen over HTTP
|
||||
reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
}
|
||||
|
||||
https:// {
|
||||
@@ -60,9 +60,9 @@ https:// {
|
||||
}
|
||||
|
||||
encode
|
||||
reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
}
|
||||
|
||||
http://localhost:2002 {
|
||||
reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3002
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3002
|
||||
}
|
||||
|
||||
@@ -53,7 +53,12 @@ func serve(listener net.Listener, serve func(http.ResponseWriter, *http.Request)
|
||||
handler = http.HandlerFunc(serve)
|
||||
handler = ObserveHTTPHandler(handler)
|
||||
handler = panicHandler(handler)
|
||||
log.Fatalln(http.Serve(listener, handler))
|
||||
|
||||
server := http.Server{Handler: handler}
|
||||
server.Protocols = new(http.Protocols)
|
||||
server.Protocols.SetHTTP1(true)
|
||||
server.Protocols.SetUnencryptedHTTP2(true)
|
||||
log.Fatalln(server.Serve(listener))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user