Bastien974
Bastien974

Reputation: 321

php CURLOPT_RESOLVE doesn't work

I'm on Centos 6, PHP 5.6.35,

curl 7.59.0 (x86_64-redhat-linux-gnu) libcurl/7.59.0 OpenSSL/1.0.1e zlib/1.2.3 c-ares/1.14.0 libssh2/1.8.0 nghttp2/1.6.0

I'm trying to force curl to use an IP (webserver in my LAN) with HTTPS :

  curl_setopt($ch, CURLOPT_URL, "https://" . $domain . "/");
  curl_setopt($ch, CURLOPT_RESOLVE, array( $domain . ":443:192.168.1.10"));
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
  curl_setopt($ch, CURLOPT_HEADER, true);
  curl_setopt($ch, CURLOPT_NOBODY, true);
  curl_setopt($ch, CURLOPT_VERBOSE, true);
  $output = curl_exec($ch);

It keeps connecting to the real public IP of $domain. I also get this :

PHP Notice: Use of undefined constant CURLOPT_RESOLVE - assumed 'CURLOPT_RESOLVE' in ...

PHP Warning: curl_setopt() expects parameter 2 to be long, string given in ...

Upvotes: 3

Views: 1645

Answers (1)

Bastien974
Bastien974

Reputation: 321

For some reason, the curl 7.59 version from city-fan doesn't work.

I've tested on a Centos 7 with

curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.21 Basic ECC zlib/1.2.7 libidn/1.28 libssh2/1.4.3

and it works.

Upvotes: 1

Related Questions