0

Here I am again with a curl question.

We are facing an issue I can't get rid of. We have two servers. Both servers have the same CURL settings. Here are the differences with the phpinfo and phpini files:

  • Server A: PHP 5.6.34
  • Server B: 5.6.33-0+deb8u1

Differences: Server B has these settings: disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, session.use_strict_mode = 0 session.gc_probability = 0

Server A has no disabled functions.

When we run the same script on both servers, server A gives the correct response, while server B throws an error. This issue is only with a few specific domains.

This is the script:

<?php
$url = "http://www.galerie-bonnard.com";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
curl_setopt($ch, CURLOPT_ENCODING, "");
curl_setopt($ch, CURLOPT_AUTOREFERER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);

var_dump(curl_exec($ch));
var_dump(curl_getinfo($ch));
var_dump(curl_error($ch)); 
?>

When we use http://google.com, both servers have the same response, while this specific domain returns a different response. According to what we see in the browser and serveral tools said, it has a redirect to another domain.

Server A returns:

string(237) "HTTP/1.1 200 OK Server: nginx Date: Tue, 20 Mar 2018 16:02:44 GMT Content-Type: text/html Content-Length: 3709 Connection: keep-alive Last-Modified: Tue, 20 Feb 2018 02:09:08 GMT ETag: "e7d-5659b4bb6aac6" Accept-Ranges: bytes " array(27) { ["url"]=> string(31) "http://www.galerie-bonnard.com/" ["content_type"]=> string(9) "text/html" ["http_code"]=> int(200) ["header_size"]=> int(237) ["request_size"]=> int(95) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.12653) ["namelookup_time"]=> float(0.124936) ["connect_time"]=> float(0.125468) ["pretransfer_time"]=> float(0.125586) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(3709) ["upload_content_length"]=> float(0) ["starttransfer_time"]=> float(0.126475) ["redirect_time"]=> float(0) ["certinfo"]=> array(0) { } ["primary_ip"]=> string(14) "xxx" ["primary_port"]=> int(80) ["local_ip"]=> string(14) "xxx" ["local_port"]=> int(58428) ["redirect_url"]=> string(0) "" ["request_header"]=> string(95) "HEAD / HTTP/1.1 Host: www.galerie-bonnard.com Accept: */* Accept-Encoding: deflate, gzip " } string(0) ""

Server B returns:

bool(false) array(26) { ["url"]=> string(31) "http://www.galerie-bonnard.com/" ["content_type"]=> NULL ["http_code"]=> int(0) ["header_size"]=> int(0) ["request_size"]=> int(0) ["filetime"]=> int(-1) ["ssl_verify_result"]=> int(0) ["redirect_count"]=> int(0) ["total_time"]=> float(0.004128) ["namelookup_time"]=> float(0) ["connect_time"]=> float(0) ["pretransfer_time"]=> float(0) ["size_upload"]=> float(0) ["size_download"]=> float(0) ["speed_download"]=> float(0) ["speed_upload"]=> float(0) ["download_content_length"]=> float(-1) ["upload_content_length"]=> float(-1) ["starttransfer_time"]=> float(0) ["redirect_time"]=> float(0) ["redirect_url"]=> string(0) "" ["primary_ip"]=> string(0) "" ["certinfo"]=> array(0) { } ["primary_port"]=> int(0) ["local_ip"]=> string(0) "" ["local_port"]=> int(0) } string(47) "Could not resolve host: www.galerie-bonnard.com"

As you can see, server A returns the correct status with the redirect, while server B throws an error: "Could not resolve host: www.galerie-bonnard.com"

I already downgraded Server A to PHP 5.4, to check if it is a PHP version related problem, but even on the lower version it works like a charm. There should be something with server B that causes this error.

Has anyone an idea what this problem/setting/update could be?

Thanks in advance!

-Frank

Frank M
  • 170
  • 3
  • 14
  • 2
    `Could not resolve host: www.galerie-bonnard.com` Looks like a DNS issue. – Jonnix Mar 20 '18 at 16:47
  • I already tried this solution: https://stackoverflow.com/questions/1341644/curl-and-https-cannot-resolve-host, but that didn't work. The strange part is that it are just 3 or 4 of a million url's and that they are working on the other server. Is there a setting that can cause this error message for specific url's? – Frank M Mar 20 '18 at 16:57

0 Answers0