Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CURLOPT_NOPROXY does not affect in PHP

Tags:

php

curl

proxy

I have http_proxy settings in my /etc/environment on my Ubuntu machine. I have defined CURLOPT_NOPROXY as 10177 and then do

$curl = curl_init('http://127.0.0.1:4444/wd/hub');
curl_setopt($curl, CURLOPT_NOPROXY, '127.0.0.1'); // or '*'
// ... set others params and options ...
curl_exec($curl);

But this does not affect my script and I receive proxy error message instead of WebDriver response. At the same time using curl --noproxy 127.0.0.1 http://127.0.0.1:4444/wd/hub from command line works well.

Additional env info:

curl --version
curl 7.22.0 (x86_64-pc-linux-gnu) 
libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 
libidn/1.23 librtmp/2.3 
Protocols: dict file ftp ftps gopher http https imap imaps ldap pop3 pop3s rtmp rtsp smtp smtps telnet tftp 
Features: GSS-Negotiate IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP 

PHP version is 5.3.10.

How can I set up noproxy option from my PHP script?

UPDATED: Looks like it should work https://bugs.php.net/bug.php?id=53543 in PHP.

like image 564
Ivan Velichko Avatar asked Sep 06 '13 08:09

Ivan Velichko


2 Answers

It happened with me so i set the proxy to empty string and it worked

curl_setopt($ch, CURLOPT_PROXY, '');
like image 162
Alaa Al Atrash Avatar answered Oct 03 '22 15:10

Alaa Al Atrash


I also had a problem with curl using a proxy only in PHP curl calls. I eventually found that SUSE specifically SLES 11 had some proxy values set. Changing those proxy values fixed issues in linux but I had to restart the entire server not just apache for the changes to take affect in PHP. I used YAST to change the proxy values on the server.

like image 30
Kevin Avatar answered Oct 03 '22 17:10

Kevin