From f747767aa10da345c19a61a63687d52876efe6a5 Mon Sep 17 00:00:00 2001 From: chrislu Date: Tue, 1 Oct 2024 12:57:45 -0700 Subject: [PATCH] support load balancer in front of s3 --- weed/s3api/auth_signature_v4.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/weed/s3api/auth_signature_v4.go b/weed/s3api/auth_signature_v4.go index 0a156cfce..71ef6cd6e 100644 --- a/weed/s3api/auth_signature_v4.go +++ b/weed/s3api/auth_signature_v4.go @@ -664,7 +664,11 @@ func extractSignedHeaders(signedHeaders []string, r *http.Request) (http.Header, extractedSignedHeaders.Set(header, "100-continue") case "host": // Go http server removes "host" from Request.Header - extractedSignedHeaders.Set(header, r.Host) + if forwardedFor := r.Header.Get("X-Forwarded-For"); forwardedFor != "" { + extractedSignedHeaders.Set(header, forwardedFor) + } else { + extractedSignedHeaders.Set(header, r.Host) + } case "transfer-encoding": for _, enc := range r.TransferEncoding { extractedSignedHeaders.Add(header, enc)