Using curl with a proxy with authentication
This is something that I need to check on quite often to test if the proxy works as expected:
curl -x <proxy-ip>:<proxy-port> http://ident.me -v --proxy-user '<proxy-username>:<proxy-password>'
Note the content in <> tags needs to be replace by the appropriate variables
The above command will hit http://ident.me via the proxy, and the IP returned should be the proxies IP
If the proxy auth fails, the response will be:
< HTTP/1.1 407 Proxy Authentication Required
< Server: squid/3.5.23
< Mime-Version: 1.0
< Date: Thu, 14 Jan 2021 13:40:28 GMT
< Content-Type: text/html;charset=utf-8
< Content-Length: 3577
< X-Squid-Error: ERR_CACHE_ACCESS_DENIED 0
< Vary: Accept-Language
< Content-Language: en
< Proxy-Authenticate: Basic realm="proxy"
< Connection: keep-alive
<
* Ignore 3577 bytes of response-body
* Received HTTP code 407 from proxy after CONNECT
* CONNECT phase completed!
* Closing connection 0
curl: (56) Received HTTP code 407 from proxy after CONNECT