- curl_setopt ($this->msh, Curlopt_httpproxytunnel, true);
- curl_setopt ($this->msh, Curlopt_proxy, $phost);
Copy CodeThere is no detail in the PHP documentation, but there is a detailed explanation in man curl, both proxies, and the Proxytunnel (-p parameter) allows other protocols to be transmitted over HTTP proxies, while the proxy (-x parameter) can only go through the HTTP protocol. So I guess, Google Baidu's server and Curl Proxytunnel, so return 403. After disabling the first sentence of the above 2 lines of code, curl access is back to normal. In addition, several operating systems are not the same, a Mac OSX will be explicitly disabled Proxytunnel, curl version:
- $ Curl--version
- Curl 7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 openssl/0.9.7l zlib/1.2.3
- Protocols:tftp ftp telnet dict ldap http file https FTPs
- Features:gss-negotiate IPv6 largefile NTLM SSL libz
Copy CodeAnd another Ubuntu is completely unaffected, how can be used, curl version:
- $ Curl--version
- Curl 7.18.2 (I486-PC-LINUX-GNU) libcurl/7.18.2 openssl/0.9.8g zlib/1.2.3.3 libidn/1.10
- Protocols:tftp ftp telnet dict ldap ldaps http file https FTPs
- Features:gss-negotiate IDN IPv6 largefile NTLM SSL libz
Copy CodeCentOS on Mt host is OK, curl version:
- $ Curl--version
- Curl 7.15.5 (I686-REDHAT-LINUX-GNU) libcurl/7.15.5 openssl/0.9.8b zlib/1.2.3 libidn/0.6.5
- Protocols:tftp ftp telnet dict ldap http file https FTPs
- Features:gss-negotiate IDN IPv6 largefile NTLM SSL libz
Copy CodeIt doesn't seem to be a completely curl version, MAC OSX is a really different thing. There is also a reason why curl returns a 403 error if it is set:
- curl_setopt ($ch, Curlopt_nobody, true);
Copy CodeYou need to follow the settings:
- curl_setopt ($ch, Curlopt_customrequest, ' GET ');
Copy CodeOtherwise, a 403 error will be returned because the HTTP server does not allow the HEAD command. Reference: Trouble with a CURL request in PHP (http://forums.devshed.com/php-development-5/ trouble-with-a-curl-request-in-php-445222.html). The reason why curl on MAC OSX is special is not ruled out. |