I have a website hosted on a Centos 6 machine running Apache. From within said website, I have an HTML form that makes a POST request to a PHP page (running in the same Centos 6 machine), whose job is, to pass on said request to a web service running in a different server via curl.
$.ajax({
method: "POST",
url: "register.php",
data: { name: name, lastname: lastname, sex: sex, bithdate: birthdate, email: email, cellphone: cellphone, country: country }
})
.always(function( msg ) {
alert( msg );
});
The PHP intermediate code:
<?php
//extra line
set_time_limit(0);
$data = http_build_query($_POST);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://xxxx:8690/register/user");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
//extra lines
curl_setopt($ch, CURLOPT_NOSIGNAL, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($ch, CURLOPT_TIMEOUT, 400); //timeout in seconds
//flags
$result = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = curl_error($ch);
echo "Error: ".$curl_error." number: ".$curl_errno;
echo "Result is: ".$result;
curl_close($ch);
?>
The problem is, when using said intermediate PHP page, the request never reaches the web service. If I make the POST request, directly from the website to web service's URL, it works perfectly, but I don't wish to do this, because I would like to keep the web service's URL private for security reasons.
Any help/ideas would be appreciated.