support proxy protocol for type http

This commit is contained in:
fatedier
2019-04-10 10:51:01 +08:00
parent 7f9d88c10a
commit b7a73d3469
5 changed files with 21 additions and 7 deletions

View File

@@ -158,6 +158,7 @@ func (p *ReverseProxy) serveWebSocket(rw http.ResponseWriter, req *http.Request)
req = req.WithContext(context.WithValue(req.Context(), "url", req.URL.Path))
req = req.WithContext(context.WithValue(req.Context(), "host", req.Host))
req = req.WithContext(context.WithValue(req.Context(), "remote", req.RemoteAddr))
targetConn, err := p.WebSocketDialContext(req.Context(), "tcp", "")
if err != nil {
@@ -215,6 +216,7 @@ func (p *ReverseProxy) serveHTTP(rw http.ResponseWriter, req *http.Request) {
// Modify for frp
outreq = outreq.WithContext(context.WithValue(outreq.Context(), "url", req.URL.Path))
outreq = outreq.WithContext(context.WithValue(outreq.Context(), "host", req.Host))
outreq = outreq.WithContext(context.WithValue(outreq.Context(), "remote", req.RemoteAddr))
p.Director(outreq)
outreq.Close = false