I offer paid videos on my website which are only available to members. At the moment, I'm doing the entire authentication and video streaming through a PHP script, however it tends to use a lot of resources and I'd like to use nginx to actually serve the file. To do that, I found you have to send the X-Accel-Redirect
header from your PHP script which then hands of the file serving to nginx.
However, there's one problem, the URL of the video to stream isn't being served by the same server as this site. It's coming from one of my other websites which is on a different VPS server (and domain) entirely. Regardless, I tried this simple test script:
<?php
header('X-Accel-Redirect: http://other-site.com/protected/videos/test.mp4');
But I don't know what to use in my nginx config to serve the file at http://other-site.com/protected/videos/test.mp4
, while still hiding the original video URL from the user.
When I access the above test script, nginx returns a 404 Not Found
and the error log has an entry like so:
open() "/var/www/site.com/web/publichttp://other-site.com/protected/videos/test.mp4" failed (2: No such file or directory)
So, nginx is obviously trying to resolve http://other-site.com/protected/videos/test.mp4
to a path in the site's document root, rather than recognising that it's a resource at another location and just "proxying" the file.
Anyone got any tips on getting this working?