John Davidson

apache - how come php curl is using proxy

0 comments
Message:


I am stuck with this problem.


I have a cakephp application on Apache server.
this feature is using curl to fetch some data like below.



$curl = curl_init($uri);
curl_setopt_array(
$curl,
[
CURLOPT_HTTPHEADER => $headers,
CURLOPT_SSL_VERIFYPEER => true,
CURLOPT_RETURNTRANSFER => true,
]
);

ob_start();
$apiContent = curl_exec($curl);

// error check
$curlErrorNo = curl_errno($curl);
$curlErrorMsg = curl_error($curl);

the problem is the curl is using proxy even I unset the env https_proxy variables.
I debugged curl error message it is like this.


 About to connect() to proxy some-proxy port 9502 (#3)
Trying 100.66.XXX.X...
Connected to some-proxy (100.66.XXX.X) port 9502 (#3)
Establish HTTP proxy tunnel to stg-platform.it.com:443
> CONNECT stg-xlatform.it.com:443 HTTP/1.1

which made curl request unsuccesful because api does NOT allow proxy.


I can bypass by set CURL_NOPROXY to curl options. But that is not the issue.


I need to know why curl is using proxy eventhough there seems to be no proxy settings at all.
Or Do I miss something here?


Your help will be really appreciated.
thanks in advance.



My Answer:
There are a few possible reasons why PHP cURL may be using a proxy even if you have unset the environment variables like https_proxy. Here are some things to check:

1. PHP cURL settings: Make sure that there are no proxy settings configured in your PHP cURL code. Check for any CURLOPT_PROXY or CURLOPT_PROXYPORT options that may be set.

2. Apache configuration: Check your Apache configuration files (such as httpd.conf or .htaccess) to see if there are any proxy settings configured at the server level that may be affecting the cURL requests.

3. Network settings: It's possible that there may be network settings or firewall rules in place that are redirecting the cURL requests through a proxy. Check with your network administrator to see if there are any network-level proxy settings that may be affecting the requests.

4. Operating system settings: Some operating systems have default proxy settings that may be affecting the cURL requests. Check your operating system settings to see if there are any proxy configurations that may be causing the issue.

By checking these different areas, you may be able to identify the source of the proxy issue and resolve it. If you continue to have trouble, you may also want to consider reaching out to the API provider for further assistance.

Rate this post

5 of 5 based on 2827 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us