PHP. Forward request to another server as is

Viewed 6922

Server A is sending messages to Server B. I need to insert Server C with PHP script between them.

So I want it to work like this:

Server A -> Server C (do some stuff with data and forward request further) -> Server B.

I need Server B to recieve exactly the same request, that was sent from server A. I don't need Server C acting as proxy, just send request as is, and that's all

How could I do it?

I've tried something like this, but in did not work:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'Server B URL');  
curl_setopt($ch, CURLOPT_HEADER, 1);  
curl_setopt($ch, CURLOPT_POST, 1);  
curl_setopt($ch, CURLOPT_VERBOSE, 1);  
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);  
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);  
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);  
curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST);
$response = curl_exec($ch);

Server B returned 200, but did nothing. I don't have access to it, so I don't know what blocked the request.

2 Answers
Related