There is a file sharing system, using the nginx platform to directly open the directory function, you can freely browse and select files to download. At the same time open ftp, you can upload files to share with everyone. All this can be achieved
It is not difficult, but after a period of time, I found that the traffic of the sharing system was high, and after analyzing the logs, I found that it was a link from Thunder from all over the world. After that, I filtered out the agent of Thunder, but the effect was not good.
Wrong, but the ensuing problem is: we usually use Xunlei, which has no effect on small files, but for files that are uploaded to G at every turn, it is a severe test for the download function of the browser.
Now, using the ngx_http_accesskey_module module and cooperating with php, a file sharing system that can prevent downloading tools and my link sharing function has been revived~
the
For nginx compilation configuration, please refer to http://wiki.nginx.org/NginxHttpAccessKeyModule
Let me share about my configuration:
nginx:
location /downloads { # autoindex on; # autoindex_localtime on; # autoindex_exact_size off; accesskey on; accesskey_hashmethod md5; accesskey_arg "key"; accesskey_signature "mypass$remote_addr"; }
PHP source code:
$downfile=$_GET["downfile"]; $dir0='/web/html/downloads'; $dir1=str_replace('..','',$_GET['dir1']); $dir=$dir0.$dir1; if ($downfile) { $filename = basename($downfile); $file=fopen($dir."/".$filename,"rb"); Header("Content-type: application/octet-stream"); Header("Accept-Ranges: bytes"); Header("Accept-Length: ".filesize($dir."/".$filenamee)); Header("Content-Disposition: attachment; filename=".$filename); echo fread($file,filesize($dir."/".$filename)); fclose($file); exit; } ?>
Shenzhou IT Architecture File Sharing System |
Please go to ftp to upload, account number: ftp password: ftpkey |
For example, your current link is: "https://www.linux-ch.com/downloads/iso/rhel-server-6.0-i386-dvd.iso? key=d85b4aa593bkdkfia450ce6a55766e6b" | '; echo '
Just delete the following "?key=d85b4aa593bkdkfia450ce6a55766e6b", and then submit it below for update> on the line | '; echo "Enter the link to update:"; echo ''; echo ''; echo ' | '; echo ''; echo '
The new download address is: |
".($durl)."?key=".$ipkey." |
'; echo "File list:"; echo ' | '; echo '
$file | \n"; echo "|||
$file | \n"; echo "$lastsave | \n"; echo "$size | \n"; echo "[Download] | \n"; echo "
Originally, the source code used the parameter urlencode to convert the link. If there was a space, there would be a problem. Then use rawurlencode to solve the problem.
The source code of php was found on the Internet, modified and processed. Here I would like to thank 3t. With his help, I can modify these files. Of course, I also want to thank the seniors who released the source code, so that I have the opportunity to modify these. Thank you.