elazarl / goproxy

An HTTP proxy library for Go
BSD 3-Clause "New" or "Revised" License
6.03k stars 1.09k forks source link

Is it possible to access the proxy address in the request handler? #282

Open socsieng opened 6 years ago

socsieng commented 6 years ago

I'd to access the proxy address that was used by the client to connect to the proxy and forward it as a request header.

For example, if I have a single instance of the proxy with dnsmasq resolving *.proxy.dev, serving team-a.proxy.dev and team-b.proxy.dev, I'd like to be able to inject a header with the proxy address on the way through.

I couldn't find a way to do this. Is it possible?

rahulwa commented 6 years ago

Yes, you can do something like https://github.com/rahulwa/camouflage/blob/master/proxy/proxy.go#L96

socsieng commented 6 years ago

The part that I was struggling with was retrieving the proxy address itself. Is it possible to determine if the request was routed via team-a.proxy.dev versus team-by.proxy.dev (using the same proxy instance)?