Handle incoming proxy requests ip, scheme (#5591)

This PR implements functions to get the right ip, scheme
from the incoming proxied requests.
This commit is contained in:
Harshavardhana
2018-03-02 15:23:04 -08:00
committed by kannappanr
parent d71b1d25f8
commit e4f6877c8b
9 changed files with 275 additions and 100 deletions

View File

@@ -28,6 +28,7 @@ import (
"github.com/gorilla/mux"
"github.com/minio/minio/pkg/auth"
"github.com/minio/minio/pkg/handlers"
"github.com/minio/minio/pkg/madmin"
)
@@ -472,17 +473,6 @@ func (a adminAPIHandlers) HealHandler(w http.ResponseWriter, r *http.Request) {
return
}
// Helper function to fetch client address - we use the
// X-forwarded-for header if one is present.
getClientAddress := func() string {
addr := r.RemoteAddr
fwdFor := r.Header.Get("X-Forwarded-For")
if fwdFor == "" {
return addr
}
return fwdFor
}
type healResp struct {
respBytes []byte
errCode APIErrorCode
@@ -530,7 +520,7 @@ func (a adminAPIHandlers) HealHandler(w http.ResponseWriter, r *http.Request) {
if clientToken == "" {
// Not a status request
nh := newHealSequence(bucket, objPrefix, getClientAddress(),
nh := newHealSequence(bucket, objPrefix, handlers.GetSourceIP(r),
numDisks, hs, forceStart)
respCh := make(chan healResp)