-1

This' been a long time on my mind. If I have some files in my documentroot (public_html) available for download and I give the download link to someone to download the file - how do I verify if it has been downloaded at all? It is a cPanel server running Apache-2.2.27. If it was an FTP account, I could look at /var/log/messages.

Is /etc/httpd/logs/access_logs a good place to start? Or is there some other explicit location I'm missing.

PS: Until now, I just used to ask 'em :)

rahuL
  • 688
  • 2
  • 12
  • 31

2 Answers2

3

You would just check your access logs for any request to the files, with a 200 response.

Although it won't tell you whether they downloaded the file, whether they cancelled it, etc... It will at least tell you that they made a request for the file.

You could even create a separate logfile purely for file access, example:

SetEnvIf Request_URI "\.(zip|exe|msi|tar|gz)$" file_dl
CustomLog logs/file_downloads.log common env=file_dl

If you wanted to know how many bytes you sent, then you need to load the mod_logio module

and then you could set up your logs like so:

LogFormat "%h %l %u %t \"%r\" %>s %b" file_bytes

SetEnvIf Request_URI "\.(zip|exe|msi|tar|gz)$" file_dl
CustomLog logs/file_downloads.log file_bytes env=file_dl

Relevant doco:

Vasili Syrakis
  • 4,435
  • 3
  • 21
  • 29
0

If this is you providing download links to people that you don't want to leave on your web server permanently then an easier to follow policy will be to tell the person the link will be available for x number of days and delete the file after that.

See the ServerFault QA Expire Files In A Folder: Delete Files After x Days for an idea on how to implement a script for that. The script is powershell but rewriting as a bash/perl/php/whatever script shouldn't be that hard. Basically it amounts to having a policy that the files being added are put into a new folder every time, then every day a script checks for folders that have a creation date older than x days and deletes the entire folder and its contents.

Otherwise I believe VasiliSyrakis has answered the actual question.

BeowulfNode42
  • 2,595
  • 2
  • 18
  • 32