I got stuck at the point:
The php script makes curl request to another php script on external ip, like
$ip = "111.222.333.444";
curl_setopt($ch, CURLOPT_URL, $this->ip . "/index.php");
I cannot modify the first script and unfortunately external ip is down forever.
So, I need to route all requests to the new same script on my server, but cannot understand how to do it better.
If there is domain name instead of ip, I can change hosts file. But it's not that case.
I googled about iptables, but how can I connect requests to exact script on my server? What changes do I need to do there?