Skip to content

Commit

Permalink
Add warning log for unsupported PROXY protocol on HTTP/3
Browse files Browse the repository at this point in the history
This commit introduces a new logging function to warn users when both HTTP/3 and HAproxy are enabled, indicating that the PROXY protocol is not supported for HTTP/3. This helps in better diagnosing configuration issues related to HTTP/3 setup.

Signed-off-by: Christian Roessner <[email protected]>
  • Loading branch information
Christian Roessner committed Aug 26, 2024
1 parent 1dde92f commit aa39fac
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions server/core/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ func serveHTTP(httpServer *http.Server, certFile, keyFile string, proxyListener
logAndExit("HTTP/1.1 and HTTP/2 server error", err)
}
} else {
logProxyHTTP3()

if err := httpServer.ServeTLS(proxyListener, certFile, keyFile); err != nil && !stderrors.Is(err, http.ErrServerClosed) {
logAndExit("HTTP/1.1 and HTTP/2 server error", err)
}
Expand All @@ -837,6 +839,15 @@ func serveHTTP(httpServer *http.Server, certFile, keyFile string, proxyListener
}
}

// logProxyHTTP3 is a function that checks if the HTTP/3 server is enabled and the HAproxy is turned on.
// If both conditions are true, it logs a warning message using the Warn level of the logger provided in the log package.
// The warning message indicates that PROXY protocol is not available for HTTP/3.
func logProxyHTTP3() {
if config.LoadableConfig.Server.HTTP3 && config.LoadableConfig.Server.HAproxyV2 {
level.Warn(log.Logger).Log(global.LogKeyMsg, "PROXY protocol not supported for HTTP/3")
}
}

// serveHTTPAndHTTP3 serves both HTTP/1.1 and HTTP/3 requests.
//
// It starts an HTTP/1.1 and HTTP/2 server in a goroutine using the provided http.Server with TLS configuration
Expand Down

0 comments on commit aa39fac

Please sign in to comment.