Skip to content

No way to retrieve the proxy host name #49007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
gadelkareem opened this issue Oct 15, 2021 · 1 comment
Closed

No way to retrieve the proxy host name #49007

gadelkareem opened this issue Oct 15, 2021 · 1 comment

Comments

@gadelkareem
Copy link

What version of Go are you using (go version)?

$ go version
1.16.4

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/gadelkareem/Library/Caches/go-build"
GOENV="/Users/gadelkareem/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/gadelkareem/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/gadelkareem/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/opt/go/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/opt/go/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.16.4"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/gadelkareem/Documents/test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/7p/qc_c3wz575z8h0000gn/T/go-build1195731376=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Running HTTP server:

package main

import (
    "fmt"
    "net"
    "net/http"
)

func main() {
    (&http.Server{
        Addr: ":8080",
        Handler: http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
                fmt.Printf("%+v\n", r.Context().Value(http.ServerContextKey).(*http.Server))
                fmt.Printf("%+v\n", r.Context().Value(http.LocalAddrContextKey).(net.Addr).String())
                fmt.Printf("%+v\n", r)
        }),
    }).ListenAndServe()
}

Run the app:

> go run main.go

Call it as a proxy: (kubernetes.docker.internal is localhost)

curl --proxy-header "Test: test" -x http://kubernetes.docker.internal:8080 -L http://google.com

What did you expect to see?

There is no way to get the original proxy host name

What did you see instead?

> go run main.go
&{Addr::8080 Handler:0x1222680 TLSConfig:0xc000001980 ReadTimeout:0s ReadHeaderTimeout:0s WriteTimeout:0s IdleTimeout:0s MaxHeaderBytes:0 TLSNextProto:map[h2:0x1216fa0] ConnState:<nil> ErrorLog:<nil> BaseContext:<nil> ConnContext:<nil> inShutdown:0 disableKeepAlives:0 nextProtoOnce:{done:1 m:{state:0 sema:0}} nextProtoErr:<nil> mu:{state:0 sema:0} listeners:map[0xc000012d00:{}] activeConn:map[0xc000112a00:{}] doneChan:<nil> onShutdown:[0x121c680]}
127.0.0.1:8080
&{Method:GET URL:http://google.com/ Proto:HTTP/1.1 ProtoMajor:1 ProtoMinor:1 Header:map[Accept:[*/*] Proxy-Connection:[Keep-Alive] Test:[test] User-Agent:[curl/7.64.1]] Body:{} GetBody:<nil> ContentLength:0 TransferEncoding:[] Close:false Host:google.com Form:map[] PostForm:map[] MultipartForm:<nil> Trailer:map[] RemoteAddr:127.0.0.1:60959 RequestURI:http://google.com/ TLS:<nil> Cancel:<nil> Response:<nil> ctx:0xc000028340}
@seankhliao
Copy link
Member

seankhliao commented Oct 15, 2021

This is a limitation of the HTTP protocol

Closing as working as intended

@golang golang locked and limited conversation to collaborators Oct 15, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants