mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
proxyRequest with ClientAddress and not localhost
This commit is contained in:
parent
02dda12e0e
commit
7d740b7c31
@ -274,7 +274,7 @@ func Listen() {
|
||||
return
|
||||
}
|
||||
|
||||
proxyRequest(w, r, tunnel, httpClient, tunnel.TunnelPort, *behindProxy)
|
||||
proxyRequest(w, r, tunnel, httpClient, "localhost", tunnel.TunnelPort, *behindProxy)
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -297,7 +297,7 @@ func (c *Client) BoreTunnel(ctx context.Context, tunnel Tunnel) error {
|
||||
httpMux := http.NewServeMux()
|
||||
|
||||
httpMux.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
|
||||
proxyRequest(w, r, tunnel, c.httpClient, tunnel.ClientPort, c.behindProxy)
|
||||
proxyRequest(w, r, tunnel, c.httpClient, tunnel.ClientAddress, tunnel.ClientPort, c.behindProxy)
|
||||
})
|
||||
|
||||
httpServer := &http.Server{
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
"time"
|
||||
)
|
||||
|
||||
func proxyRequest(w http.ResponseWriter, r *http.Request, tunnel Tunnel, httpClient *http.Client, port int, behindProxy bool) {
|
||||
func proxyRequest(w http.ResponseWriter, r *http.Request, tunnel Tunnel, httpClient *http.Client, address string, port int, behindProxy bool) {
|
||||
|
||||
if tunnel.AuthUsername != "" || tunnel.AuthPassword != "" {
|
||||
username, password, ok := r.BasicAuth()
|
||||
@ -29,9 +29,7 @@ func proxyRequest(w http.ResponseWriter, r *http.Request, tunnel Tunnel, httpCli
|
||||
|
||||
downstreamReqHeaders := r.Header.Clone()
|
||||
|
||||
// TODO: should probably pass in address instead of using localhost,
|
||||
// mostly for client-terminated TLS
|
||||
upstreamAddr := fmt.Sprintf("localhost:%d", port)
|
||||
upstreamAddr := fmt.Sprintf("%s:%d", address, port)
|
||||
upstreamUrl := fmt.Sprintf("http://%s%s", upstreamAddr, r.URL.RequestURI())
|
||||
|
||||
upstreamReq, err := http.NewRequest(r.Method, upstreamUrl, r.Body)
|
||||
|
Loading…
Reference in New Issue
Block a user