mirror of
https://github.com/pgsty/minio.git
synced 2026-07-20 12:40:24 +03:00
List v1/versions routes based on source IP if found (#10603)
Routing using on source IP if found. This should distribute the listing load for V1 and versioning on multiple nodes evenly between different clients. If source IP is not found from the http request header, then falls back to bucket name instead.
This commit is contained in:
+10
-4
@@ -74,10 +74,9 @@ func GetSourceScheme(r *http.Request) string {
|
||||
return scheme
|
||||
}
|
||||
|
||||
// GetSourceIP retrieves the IP from the X-Forwarded-For, X-Real-IP and RFC7239
|
||||
// Forwarded headers (in that order), falls back to r.RemoteAddr when all
|
||||
// else fails.
|
||||
func GetSourceIP(r *http.Request) string {
|
||||
// GetSourceIPFromHeaders retrieves the IP from the X-Forwarded-For, X-Real-IP
|
||||
// and RFC7239 Forwarded headers (in that order)
|
||||
func GetSourceIPFromHeaders(r *http.Request) string {
|
||||
var addr string
|
||||
|
||||
if fwd := r.Header.Get(xForwardedFor); fwd != "" {
|
||||
@@ -106,6 +105,13 @@ func GetSourceIP(r *http.Request) string {
|
||||
}
|
||||
}
|
||||
|
||||
return addr
|
||||
}
|
||||
|
||||
// GetSourceIP retrieves the IP from the request headers
|
||||
// and falls back to r.RemoteAddr when necessary.
|
||||
func GetSourceIP(r *http.Request) string {
|
||||
addr := GetSourceIPFromHeaders(r)
|
||||
if addr != "" {
|
||||
return addr
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user