title: Nodejs websocket request to php
body: <p>I have a Nodejs websocket that forward incoming request to php.</p>
  <p>How to know if this php call are going outside the server or it is internally?</p>
  <p>Server has more than one Domain: <a href="http://www.example1.com" rel="nofollow noreferrer">www.example1.com</a> and <a href="http://www.example2.com" rel="nofollow noreferrer">www.example2.com</a></p>
  <p>websocket call to php:</p>
  <pre><code>phpURL = 'https://www.example1.com/sub/function.php';
  
  var options = {
    method: 'post',
    body: param, 
    json: true, 
    rejectUnauthorized: false,
    requestCert: false,
    agent: false,
    url: phpURL,
    headers: {
       
      'Cookie': ck
    }
  }
  
  request(options, function (err, res, body) {
   
          try{  
              var allReq = body.split(&quot;------&quot;);
              for(var i=0;i&lt;allReq.length;i++){
                  ws.send(allReq[i]);  
              }
          }catch(e){
              console.log('Error :', e)
              return; 
          }
  
      });
  </code></pre>
  <p>The php call normally is fast but sometime
  get slow.
  Apache take time to accept the request.</p>