internal: add default go http server timeouts (#17858)

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
This commit is contained in:
Jens L.
2025-11-01 19:04:13 +01:00
committed by GitHub
parent 09e3301c8f
commit 894db1237a
3 changed files with 19 additions and 4 deletions
+1 -1
View File
@@ -195,7 +195,7 @@ func (ps *ProxyServer) Stop() error {
}
func (ps *ProxyServer) serve(listener net.Listener) {
srv := &http.Server{Handler: ps.mux}
srv := web.Server(ps.mux)
// See https://golang.org/pkg/net/http/#Server.Shutdown
idleConnsClosed := make(chan struct{})
+17
View File
@@ -0,0 +1,17 @@
package web
import (
"net/http"
"time"
)
func Server(h http.Handler) *http.Server {
return &http.Server{
Handler: h,
ReadHeaderTimeout: 5 * time.Second,
ReadTimeout: 30 * time.Second,
WriteTimeout: 60 * time.Second,
IdleTimeout: 120 * time.Second,
MaxHeaderBytes: http.DefaultMaxHeaderBytes,
}
}
+1 -3
View File
@@ -241,9 +241,7 @@ func (ws *WebServer) listenPlain() {
}
func (ws *WebServer) serve(listener net.Listener) {
srv := &http.Server{
Handler: ws.mainRouter,
}
srv := web.Server(ws.mainRouter)
// See https://golang.org/pkg/net/http/#Server.Shutdown
idleConnsClosed := make(chan struct{})