add proxy mode to read non-local volumes

This commit is contained in:
zhangsong
2021-06-30 18:33:18 +08:00
parent 7566782c2e
commit 20d33ae025
3 changed files with 2 additions and 4 deletions

View File

@@ -1,7 +1,6 @@
package weed_server
import (
"fmt"
"net/http"
"strconv"
"strings"
@@ -82,7 +81,6 @@ func getContentLength(r *http.Request) int64 {
}
func (vs *VolumeServer) publicReadOnlyHandler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("publicReadOnlyHandler in.")
w.Header().Set("Server", "SeaweedFS Volume "+util.VERSION)
if r.Header.Get("Origin") != "" {
w.Header().Set("Access-Control-Allow-Origin", "*")

View File

@@ -70,7 +70,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
w.WriteHeader(http.StatusNotFound)
return
}
if vs.ReadMode == "remote" {
if vs.ReadMode == "proxy" {
// proxy client request to target server
u, _ := url.Parse(util.NormalizeUrl(lookupResult.Locations[0].Url))
r.URL.Host = u.Host