{"id":15015355,"url":"https://github.com/awarmanf/file_upload_cgi","last_synced_at":"2026-03-16T22:04:25.717Z","repository":{"id":254682864,"uuid":"847251896","full_name":"awarmanf/file_upload_cgi","owner":"awarmanf","description":"The File Upload CGI is a web application written in Perl CGI to limit the upload rate of a file to user.","archived":false,"fork":false,"pushed_at":"2024-08-25T09:38:50.000Z","size":1030,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-19T17:09:59.842Z","etag":null,"topics":["cgi","nginx","perl"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awarmanf.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-08-25T09:34:50.000Z","updated_at":"2024-08-25T09:38:53.000Z","dependencies_parsed_at":"2024-08-25T10:54:41.228Z","dependency_job_id":null,"html_url":"https://github.com/awarmanf/file_upload_cgi","commit_stats":null,"previous_names":["awarmanf/file_upload_cgi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awarmanf%2Ffile_upload_cgi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awarmanf%2Ffile_upload_cgi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awarmanf%2Ffile_upload_cgi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awarmanf%2Ffile_upload_cgi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awarmanf","download_url":"https://codeload.github.com/awarmanf/file_upload_cgi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243313409,"owners_count":20271178,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cgi","nginx","perl"],"created_at":"2024-09-24T19:46:58.512Z","updated_at":"2025-12-28T22:37:28.426Z","avatar_url":"https://github.com/awarmanf.png","language":"Perl","readme":"\n# File Upload CGI\n\nThe File Upload CGI is a web application written in Perl CGI to limit the upload rate of a file to user.\n\n\u003eThis application is written on Debian Linux (Jessie).\n\n## Features\n\n* Support resuming download\n* Limit traffic download user to specified speed\n* Only allow one session download for unique ip address \u0026 user agent\n\n## Requirement\n\nYou must install nginx, mysql and perl cgi.\n\nConfigure nginx to use `rewrite` rule. Edit file `/etc/nginx/sites-enabled/default`\n\n```nginx\nserver {\n  listen 80;\n  listen [::]:80;\n\n  # SSL configuration\n  #\n  listen 443 ssl;\n  listen [::]:443 ssl;\n  include snippets/yoursites.org.conf;\n\n  server_name yoursites.org;\n  access_log /var/www/html/yoursites.org/logs/access.log;\n  error_log /var/www/html/yoursites.org/logs/error.log;\n\n  root   /var/www/html/yoursites.org/public_html;\n  index  index.html index.htm index.php;\n\n  rewrite ^/files/(.*)$ /cgi/getfile.cgi?f=$1 last;\n\n  include php-fastcgi;\n  include perl-fastcgi;\n}\n```\n\n## Create directory for hostname yoursites.org\n\n```\nmkdir /var/www/html/yoursites.org\nmkdir /var/www/html/yoursites.org/{files,logs,public_html,public_html/cgi}\n```\n\nSave the script `getfile.cgi` at directory `/var/www/html/yoursites.org/public_html/cgi`\n\n## Create database upload\n\nLogin to mysql as user root\n\n```sql\nCREATE DATABASE upload;\nCREATE USER 'user1'@'localhost' IDENTIFIED BY 'password1';\nGRANT ALL PRIVILEGES ON `smscgi` . * TO 'user1'@'localhost';\nQUIT;\n```\n\nThen execute sql statements on file `smscgi.db`\n\n```\nmysql -u user1 -p upload \u003c upload.db\n```\n\n## Create file dummy\n\nCreate file dummy 1MB and 10MB and save at directory `/var/www/html/yoursites.org/files`\n\n```\nDST=/var/www/html/yoursites.org/files\ndd if=/dev/urandom of=${DST}/file-1MB.dat bs=1M count=1\ndd if=/dev/urandom of=${DST}/file-10MB.dat bs=1M count=10\n```\n\n## Test download file\n\nRestart nginx\n\n```\n/etc/init.d/nginx restart\n```\n\nUsing wget download the file `file-1MB.dat`\n\n```\n$ wget http://yoursites.org/files/file-1MB.dat\n--2024-08-25 15:34:15--  http://yoursites.org/files/file-1MB.dat\nResolving yoursites.org (yoursites.org)... 1.2.3.4\nConnecting to yoursites.org (yoursites.org)|1.2.3.4|:80... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: 1048576 (1,0M) [application/x-download]\nSaving to: ‘file-1MB.dat’\n\nfile-1MB.dat           100%[==================================\u003e]   1,00M   112KB/s    in 9,1s    \n\n2024-08-25 15:34:24 (112 KB/s) - ‘file-1MB.dat’ saved [1048576/1048576]\n```\n\n## Show log upload\n\n```sql\nmysql\u003e select * from getfile;\n+----+---------------+-------------+------------+---------------------+\n| id | filename      | ua          | ip         | date                |\n+----+---------------+-------------+------------+---------------------+\n| 1  | file-10MB.dat | Wget/1.21.2 | 103.47.1.2 | 2024-08-25 17:01:10 |\n| 2  | file-10MB.dat | Wget/1.21.2 | 103.47.1.2 | 2024-08-25 17:02:17 |\n+----+---------------+-------------+------------+---------------------+\n2 rows in set (0.01 sec)\n\nmysql\u003e select * from log limit 3701,3703;\n+----+------------+-------------+------------------+-------+--------+\n| id | ip         | ua          | stime            | etime | status |\n+----+------------+-------------+------------------+-------+--------+\n| 1  | 103.47.1.2 | Wget/1.21.2 | 1724579980.00809 |     2 |      1 |\n| 2  | 103.47.1.2 | Wget/1.21.2 | 1724580083.71145 |     2 |      1 |\n+----+------------+-------------+------------------+-------+--------+\n2 rows in set (0.00 sec)\n```\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawarmanf%2Ffile_upload_cgi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawarmanf%2Ffile_upload_cgi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawarmanf%2Ffile_upload_cgi/lists"}