mirror of
https://codeberg.org/git-pages/git-pages.git
synced 2026-08-17 01:16:06 +00:00
Add a feature flag for testing h2c:// performance.
This commit is contained in:
+10
-4
@@ -27,7 +27,7 @@
|
||||
auto_https disable_redirects
|
||||
|
||||
on_demand_tls {
|
||||
permission http http://{$GIT_PAGES_ADDRESS:localhost}:3001
|
||||
permission http http://localhost:3001
|
||||
}
|
||||
|
||||
servers :80 {
|
||||
@@ -46,12 +46,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
(backend_pages) {
|
||||
@h2c `{env.FEATURES}.matches(r"\bh2c\b")`
|
||||
reverse_proxy @h2c h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
reverse_proxy http://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
}
|
||||
|
||||
http:// {
|
||||
@get method GET
|
||||
redir @get https://{host}{uri} 301
|
||||
|
||||
# initial PUT/POST for a new domain has to happen over HTTP
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
import backend_pages
|
||||
}
|
||||
|
||||
https:// {
|
||||
@@ -60,9 +66,9 @@ https:// {
|
||||
}
|
||||
|
||||
encode
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3000
|
||||
import backend_pages
|
||||
}
|
||||
|
||||
http://localhost:2002 {
|
||||
reverse_proxy h2c://{$GIT_PAGES_ADDRESS:localhost}:3002
|
||||
reverse_proxy http://localhost:3002
|
||||
}
|
||||
|
||||
+14
-1
@@ -7,12 +7,23 @@ import (
|
||||
"log/slog"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime/debug"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/KimMachineGun/automemlimit/memlimit"
|
||||
)
|
||||
|
||||
var features []string
|
||||
|
||||
func FeatureActive(feature string) bool {
|
||||
if features == nil {
|
||||
features = strings.Split(strings.ToLower(os.Getenv("FEATURES")), ",")
|
||||
}
|
||||
return slices.Contains(features, strings.ToLower(feature))
|
||||
}
|
||||
|
||||
func listen(name string, listen string) net.Listener {
|
||||
if listen == "" {
|
||||
return nil
|
||||
@@ -57,7 +68,9 @@ func serve(listener net.Listener, serve func(http.ResponseWriter, *http.Request)
|
||||
server := http.Server{Handler: handler}
|
||||
server.Protocols = new(http.Protocols)
|
||||
server.Protocols.SetHTTP1(true)
|
||||
server.Protocols.SetUnencryptedHTTP2(true)
|
||||
if FeatureActive("h2c") {
|
||||
server.Protocols.SetUnencryptedHTTP2(true)
|
||||
}
|
||||
log.Fatalln(server.Serve(listener))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user