Skip to content

Commit b670cdd

Browse files
author
胡照伦
committed
调整websocket适应2
1 parent 233b5d3 commit b670cdd

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

server/proxy/http.go

+2
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func (rp *HttpReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
132132
return
133133
}
134134
if host.Client.Cnf.U != "" && host.Client.Cnf.P != "" && !common.CheckAuth(req, host.Client.Cnf.U, host.Client.Cnf.P) {
135+
rw.Header().Set("WWW-Authenticate", "Basic realm=\"Private Area\"")
135136
rw.WriteHeader(http.StatusUnauthorized)
136137
rw.Write([]byte("Unauthorized"))
137138
return
@@ -141,6 +142,7 @@ func (rp *HttpReverseProxy) ServeHTTP(rw http.ResponseWriter, req *http.Request)
141142
rw.Write([]byte("502 Bad Gateway"))
142143
return
143144
}
145+
req.URL.Host = req.Host
144146
req = req.WithContext(context.WithValue(req.Context(), "host", host))
145147
req = req.WithContext(context.WithValue(req.Context(), "target", targetAddr))
146148
req = req.WithContext(context.WithValue(req.Context(), "req", req))

0 commit comments

Comments
 (0)