title: How secure is to assume that if $_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR'], is the server the one making the request?
body: <p>Well, the question says it all, i am wondering, how secure is a comparison like:</p>
  
  <pre><code>if ($_SERVER['SERVER_ADDR'] === $_SERVER['REMOTE_ADDR']) {
      // yeah, it's the server, go ahead do this.
  }
  </code></pre>
  
  <p>The reason why i am asking is to identify some web api calls that are coming from the server itself.  </p>
  
  <p>I know that the <code>$_SERVER['REMOTE_ADDR']</code> can be spoofed to run a request but not to get the result back from it. If this is the case, when talking about Rest for example, this rises no problem for GET requests for instance, but how about DELETE requests, where there is no need to parse the response from the server.<br>
  If the above statement is correct, means you should't trust the aftermentioned comparison?<br>
  What are the alternatives (let's exclude CLI from here) ?</p>