简单的 HTTP 文件共享服务 – FileBox

FileBox 是一个基于 HTTP 的简单文件共享服务,支持匿名的文件上传与下载、文件有效期限管理等。它实现为 HevSCGIServer 的一个 Handler,通过 SCGI 协议与 Web Server 交互。

filebox

安装部署
1. Web Server (Nginx)
Nginx 自身的安装部署就不多说了,主要说一下与 HevSCGIServerFilebox 相关的配置文件部分:

server {
    ...
 
    location /scgi {
        client_max_body_size 1024m; # 限制每组最大上传大小
        scgi_pass   127.0.0.1:9000; # HevSCGIServer 侦听地址端口
        #scgi_pass   unix:/opt/extra/hev-scgi-server/run/conn.sock; # 安全配置建议使用 Unix Socket
        include     scgi_params;
    }
 
    ...
}

2. HevSCGIServer Core
a. 创建目录结构

mkdir -p /opt/extra/hev-scgi-server/{bin,conf,lib/modules,run}
mkdir -p /var/lib/hev-scgi-server/filebox/{pool,meta,temp}

b. 下载、安装 hev-scgi-server-library

git clone git://gitcafe.com/heiher/hev-scgi-server-library.git
cd hev-scgi-server-library
make
cp bin/libhev-scgi-server.so /opt/extra/hev-scgi-server/lib/

c. 下载、安装 hev-scgi-server

git clone git://gitcafe.com/heiher/hev-scgi-server.git
cd hev-scgi-server
make
cp bin/hev-scgi-server /opt/extra/hev-scgi-server/bin/

3. FileBox

git clone git://gitcafe.com/heiher/hev-scgi-handler-filebox.git
cd hev-scgi-handler-filebox
make
cp bin/libhev-scgi-handler-filebox.so /opt/extra/hev-scgi-server/lib/modules/
cp -r ui/* /srv/http/ # 复制到 Web 根目录

4. 配置文件
/opt/extra/hev-scgi-server/conf/main.conf

[Server]
Address=127.0.0.1:9000
ModuleDirPath=/opt/extra/hev-scgi-server/lib/modules

/opt/extra/hev-scgi-server/conf/modules.conf

[Module0]
Alias=HevSCGIHandlerFilebox
Pattern=^/scgi/fb((/|\\?)(.*))?$
FileName=libhev-scgi-handler-filebox.so
 
BaseURI=/scgi/fb/
CleanInterval=600
FilePoolPath=/var/lib/hev-scgi-server/filebox/pool
FileMetaPath=/var/lib/hev-scgi-server/filebox/meta
FileTempPath=/var/lib/hev-scgi-server/filebox/temp

Tips: 命令行上传

curl -i -F filedata=@文件名称 -F one-off=true http://127.0.0.1/scgi/fb/upload # one-off=true 即“下后即删”

Over!

Leave a Reply

Your email address will not be published. Required fields are marked *