Golang how to use forward http proxy – Best way to configure it? or How to set up a forward HTTP prox

18 Replies, 1524 Views

If you’re stuck on golang how to use forward http proxy, this might help:

```go
func newProxyClient(proxyAddr string) *http.Client {
proxy, _ := url.Parse(proxyAddr)
return &http.Client{
Transport: &http.Transport{Proxy: http.ProxyURL(proxy)},
}
}
```

Bonus: Use `curl -x` to test your proxy manually first. Saves a ton of debugging time.

Messages In This Thread



Users browsing this thread: 1 Guest(s)