I have a Server A
which has a database of valid download tokens.
If the user provides a valid token (present in the database), a large file (> 2 GB) will be available as download for them. Currently, I do (as detailed in Fastest Way to Serve a File Using PHP and Downloading files with download.php):
<?php
$ok = check_token_in_database($_GET['token']); // internally uses a SQLite DB
$file = "bigfile.zip";
if ($ok) {
header("X-Sendfile: /path/to/" . $file);
header("Content-type: application/octet-stream");
header('Content-Disposition: attachment; filename="' . $file . '"');
}
It works, but now I need to lighten the load of Server A
, and I would like, if the token is valid, to serve the file from another Server B
. I was thinking about:
<?php
$ok = check_token_in_database($_GET['token']);
if ($ok) {
header("Location: https://server_b.example.com/obfuscated_url_ff87a45d76apZ/bigfile.zip");
but then, anyone will probably be able to find the destination link https://server_b.example.com/obfuscated_url_ff87a45d76apZ/bigfile.zip
and they can share it with other people, which I don't want.
How to handle this situation, without having to move the token database and the token check to Server B
?