I have a PHP application to check the users access(user/pass) and if the access is true, serve them the file for downloading by sending nginx's X-Accel-Redirect
header to user.
The problem shows up when a user can share his login information(user/pass) with other people; so everyone have the login information can access the files and download them. I continue describing my problem by an example.
For example,
think we have two peoples who sharing their login access. so they both using a same User/Pass to loging in. let's call them "User_1
" and "User_2
".
User_1
loging in and start to download the file. at the same time, User_2
trying to loging in too. here, my php application noticed about the second login try.
I have their (ip address, user-agent, session_id) and I also can find out which file is already downloading by User_1
.
When the User_2
trying to login, I will delete the User_1
's session in php/mysql and if User_1
wants to download again, he have to re-login. I can even simply suspend this account(User/Pass), so no one can use it again!
But the problem is that X-Accel-Redirect
already sent to User_1
for his previous login and download keeps continuing even if I delete the php sessions and force to loging out User_1
!
So, I need a way to terminate User_1
's alive download connection.
so, make it impossible to more than one download from the same user/pass at a same time.