linux - with - php curl proxy authentication
performing HTTP requests with cURL(using PROXY) (10)
Beware that if you are using a SOCKS proxy, instead of a HTTP/HTTPS proxy, you will need to use the
--socks5 switch instead:
curl --socks5 126.96.36.199:8909 http://example.com/
I have this proxy address:
How can I perform a HTTP request using cURL like
curl http://www.example.com, but specifying the proxy address of my network?
Depending on your workplace, you may also need to specify the
-k or the
--insecure option for curl in order to get past potential issues with CA certificates.
curl -x <myCompanyProxy>:<port> -k -O -L <link to file to download>
-x, --proxy <[protocol://][user:[email protected]]proxyhost[:port]> Use the specified HTTP proxy. If the port number is not specified, it is assumed at port 1080.
Then you can connect through proxy from (many) application.
And, as per comment below, for https:
And if the proxy needs authentication, we can first use a normal web-browser to access the website which will promote authentication dialog. After authentication, we can use wireshark to capture the http package sends to the proxy server, from the http package, we can get the auth token from http header: Proxy-Authorization
Then we can set the http_proxy environment variable and also include auth token in the http header: Proxy-Authorization
curl -H "Proxy-Authorization: xxxx" http://targetURL
Just summarizing all great mentioned answers:
curl -x http://<user>:<pass>@<proxyhost>:<port>/ -o <filename> -L <link>
With a proxy with authentication I use:
curl -x <protocol>://<user>:<password>@<host>:<port> --proxy-anyauth <url>
because, I don't know why curl doesn't use/catch http[s]_proxy environment variables.
You don't need to export the
http[s]_proxy shell variable if you're just setting the proxy for a one off command. e.g.
http_proxy=http://your.proxy.server:port curl http://www.example.com
That said, I'd prefer
curl -x if I knew I was always going to use a proxy.
use the following
curl -I -x 192.168.X.X:XX http://google.com
192.168.X.X:XX put your proxy server ip and port.
-v verbose mode it will give more details including headers and response.
you can use :
curl http://www.example.com --proxy http://188.8.131.52:8909
as explained by Karl