简体   繁体   中英

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 ...

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM