There is a really nice nginx module that does this.
The URL receives two parameters - Lets call them s (security) and t (timestamp). Security is a secure hash generated from a timestamp, path and salt (in your case, just add ip).
$ip = $_SERVER['REMOTE_ADDR'];
$salt = 'change me cause im not secure';
$path = '/download/webapp.rar';
$timestamp = time() + 3600;
$hash = md5($salt . $ip . $timestamp . $path);
$url = "http://mysite.com{$path}?s={$hash}&t={$timestamp}";
To check:
$ip = $_SERVER['REMOTE_ADDR'];
$salt = 'change me cause im not secure';
$path = $_SERVER['REQUEST_URI'];
$hashGiven = $_GET['s'];
$timestamp = $_GET['t'];
$hash = md5($salt . $ip . $timestamp . $path);
if($hashGiven == $hash && $timestamp <= time()) {
// serve file
} else {
die('link expired or invalid');
}
" " - script, .
nginx:
location /download {
rewrite ^.*$ /download.php last;
break;
}
apache, .
, , , , , URL- (. ).
nginx: http://wiki.nginx.org/HttpSecureLinkModule
lighty: http://redmine.lighttpd.net/wiki/1/Docs:ModSecDownload
nginx: http://wiki.nginx.org/HttpSecureDownload
, - apache ... , - ...