Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use proxies with authentication in my HTTP requests?

I have a proxy IP Address (that also require a username and password). When i try using them to visit webpages, i get "Proxy Authentication Required".

I'm found this other Stackoverflow post from 2016, and this Github Issue that was closed, but they don't provide anything useful:

  • Proxy golang https
  • https://github.com/golang/go/issues/22288

Any suggestions?

EDIT: Saw this post: Setting up proxy for HTTP client

It's kinda close. However, for some urls I'm able to get a successful response using my proxy, but for certain urls, I get a "Proxy Authorization Required".

like image 840
Matthew Avatar asked Nov 21 '18 07:11

Matthew


People also ask

What is HTTP Proxy authentication?

The HTTP Proxy-Authenticate response header defines the authentication method that should be used to gain access to a resource behind a proxy server. It authenticates the request to the proxy server, allowing it to transmit the request further.

How does proxy work with HTTP?

An HTTP Proxy serves two intermediary roles as an HTTP Client and an HTTP Server for security, management, and caching functionality. The HTTP Proxy routes HTTP Client requests from a Web browser to the Internet, while supporting the caching of Internet data.

How do I fix proxy authentication required?

If you are behind a firewall, you will need to configure your firewall settings to allow access to the proxy server. Once you have the correct proxy settings, the 407 Proxy Authentication Required error should be fixed.


1 Answers

If you're following this authorized proxy tutorial, the additional step you would have to do is to set up the HEADER in the transport.

auth := "username:password"
basicAuth := "Basic " + base64.StdEncoding.EncodeToString([]byte(auth))
transport.ProxyConnectHeader = http.Header{}
transport.ProxyConnectHeader.Add("Proxy-Authorization", basicAuth)
like image 58
Juan Avatar answered Oct 12 '22 07:10

Juan