title: PHP restrict page requests to a specific server?
body: <p>Basically my script streams an mp3 file that's outside of web root. My script is called from another website via inside an audio tag, if that makes sense. Here's how it looks:</p>
  
  <p><code>Webiste #2:</code></p>
  
  <pre><code>&lt;audio src="http://website#1.com/getMp3?file=somehashedvalue"&gt;&lt;/audio&gt;
  </code></pre>
  
  <p>The idea is that I want to only allow website #2 to get this stream, meaning if you were to go directly to <code>http://website#1.com/getMp3?file=somehashedvalue</code> you would get a 404.</p>
  
  <p>In my <code>getMp3.php</code> class (hosted on website #1), this does NOT work:</p>
  
  <pre><code>$whitelist = $this-&gt;getWhitelist();
  $ip = $_SERVER['REMOTE_ADDR'];
  
  if( !in_array( $ip, $whitelist ) {
      header('HTTP/1.0 404 Not Found');
      exit;
  } else {
      //continue
  }
  </code></pre>
  
  <p>When looking at the logs, the request on <code>Website #1</code> coming from <code>Website #2</code> is actually the client's IP Address.</p>
  
  <p>Any ideas as to how I can get the IP address of <code>Website #2</code>?</p>