I have a tomcat server (Server A) which has a ton of progressively streaming encoded mp4 video and mp3 audio files and is on a private network. I also have a web server (Server B) running Apache 2 and PHP which is on the private network and has a public facing interface. Server B manages application ACL.
I want a client (say a browser) to be able to go to a specific url on Server B's public interface, and be able to download, (listen or view in a player) the media from the private server. At the moment, on server B, I have tried the following:
<?php
$handler = fopen('http://server_a/path/to/file.mp4', 'r');
header('Content-type: video/mp4');
while (!feof($handler)) {
print fread($handler, 8192);
}
exit;
and
<?php
$handler = fopen('http://server_a/path/to/file.mp4', 'r');
header('Content-type: video/mp4');
print stream_get_contents($handler);
exit;
and
<?php
$handler = fopen('http://server_a/path/to/file.mp4', 'r');
header('Content-type: video/mp4');
fpassthru($handler);
exit;
All of which PHP will either run out of memory or the client (browser) will download the entire file before even beginning to play. Am I going the wrong way about this? Any ideas on what I could be doing wrong?