cURL with the real server IP while using CloudFlare
yeah well, if clients.domain.com
is going through CF's proxy, then you could connect directly to the server, and probably just fake the host header. as of PHP 7.0.7, this can be done as
curl_setopt_array($ch,array(CURLOPT_URL=>'http://clients.domain.com/api',//to set the host CURLOPT_CONNECT_TO=>'::8.8.8.8:80'));
- but replace :80
with :443
if you're connecting with httpS
and replace 8.8.8.8
with the real server's IP (not the cloudflare IP)
or if you're not on PHP 7.0.7+ yet, in older versions, you can do
curl_setopt_array($ch,array(CURLOPT_URL=>'http://8.8.8.8/api',CURLOPT_HTTPHEADER=>array('Host: clients.domain.com')));
(again, replace 8.8.8.8
with the real server's IP, not the cloudflare IP)to set the host header manually. im not sure that will work properly with http Location redirects and CURLOPT_FOLLOWLOCATION, though, so you might have to handle Location http redirects manually