Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-14 Thread Michael Baker
On 14/04/2021 20:25, Jeff Peck wrote: Just a complete shot in the dark. Have you verified that the environment variables you set are indeed getting picked up inside of your application? Try checking the output of os.GetEnv("HTTP_PROXY"), os.GetEnv("HTTPS_PROXY"), and os.GetEnv("NO_PROXY").

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-14 Thread Jeff Peck
Just a complete shot in the dark. Have you verified that the environment variables you set are indeed getting picked up inside of your application? Try checking the output of os.GetEnv("HTTP_PROXY"), os.GetEnv("HTTPS_PROXY"), and os.GetEnv("NO_PROXY"). Make sure that if NO_PROXY is set that it

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-14 Thread Orson Cart
On Wednesday, 14 April 2021 at 18:06:53 UTC+1 Adrian Ho wrote: > The "Name Resolution" section in https://golang.org/pkg/net/ says: > > On Unix systems, the resolver has two options for resolving names. It can > use a pure Go resolver that sends DNS requests directly to the servers > listed

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-14 Thread Adrian Ho
On 14/4/21 6:39 am, Orson Cart wrote: So, to clarify: 1/ I have a proxy (Fiddler) running locally on port 2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler 3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to http://fiddler:  and

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Adrian Ho
On 14/4/21 6:39 am, Orson Cart wrote: So, to clarify: 1/ I have a proxy (Fiddler) running locally on port 2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler 3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to http://fiddler:  and

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Orson Cart
So, to clarify: 1/ I have a proxy (Fiddler) running locally on port 2/ my /etc/hosts file has an entry as follows: 127.0.0.1 fiddler 3/ My HTTP_PROXY and HTTPS_PROXY environment variables are set to http://fiddler: and https://fiddler:

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Orson Cart
So, to clarify: With my HTTP_PROXY and HTTPS_PROXY environment variables set to http://localhost: and https://localhost: respectively, if I issue a request via curl then that request is picked up by the proxy. However if I make the same request from my go application, the request

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Orson Cart
Thanks for the reply. Yes I did add an alias to the /etc/hosts file and it makes no difference. The requests still bypass the proxy. As you point out it's possible to achieve the goal in code but I'd really like to do it without changing the code if at all possible. I'm also just really

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread 'wagner riffel' via golang-nuts
On Tue Apr 13, 2021 at 7:07 PM UTC, Orson Cart wrote: > I'm perplexed :( > Did you tried the /etc/hosts? I think that would do it, if not, something like this may do the trick: if debug { t := http.DefaultTransport.(*http.Transport) t.Proxy = func(r *http.Request) (*url.URL,

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread Orson Cart
Please accept my ay apologies. I'd misunderstood the documentation. I was looking for a reason why my go application's requests aren't being sent to the proxy that I've specified using HTTP_PROXY and HTTPS_PROXY. When I saw the comment in the documentation I thought I'd found an explanation

Re: [go-nuts] Why does Go ignore HTTP_PROXY and HTTPS_PROXY if the proxy address is localhost

2021-04-13 Thread 'wagner riffel' via golang-nuts
On Tue Apr 13, 2021 at 2:14 PM -03, Orson Cart wrote: > Can anyone explain the reasoning behind this? It rather interferes with > debugging traffic using a local proxy like Fiddler. > My guess here it's for preventing the remote from tricking the proxy to make request to internal services that