diff --git a/registry/storage/driver/middleware/redirect/middleware.go b/registry/storage/driver/middleware/redirect/middleware.go index 8f63674c6..dca6584a3 100644 --- a/registry/storage/driver/middleware/redirect/middleware.go +++ b/registry/storage/driver/middleware/redirect/middleware.go @@ -13,6 +13,7 @@ type redirectStorageMiddleware struct { storagedriver.StorageDriver scheme string host string + path string } var _ storagedriver.StorageDriver = &redirectStorageMiddleware{} @@ -37,10 +38,13 @@ func newRedirectStorageMiddleware(sd storagedriver.StorageDriver, options map[st return nil, fmt.Errorf("no host specified for redirect baseurl") } - return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host}, nil + return &redirectStorageMiddleware{StorageDriver: sd, scheme: u.Scheme, host: u.Host, path: u.Path}, nil } func (r *redirectStorageMiddleware) URLFor(ctx context.Context, path string, options map[string]interface{}) (string, error) { + if r.path != "" { + path = r.path + path + } u := &url.URL{Scheme: r.scheme, Host: r.host, Path: path} return u.String(), nil }