原文地址:https://lala.im/4722.html,請支持原作者!該處僅作轉載。
psitransfer是一个非常简约的临时网盘程序,主要功能如下:
1.支持上传超大的文件\n2.可恢复的上传与下载\n3.设置文件到期时间\n4.一次性下载,即阅后即焚\n5.打包下载(ZIP/TAR.GZ)\n6.图片预览\n7.加密分享
这个网盘安装很简单,下面我在CentOS7X64上面部署。
首先安装EPEL源:
yum -y install epel-release
安装开发工具包:
yum -y groupinstall "Development Tools"
安装Node.js:
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum -y install nodejs
下载psitransfer的源码解压并进入到根目录:
wget https://github.com/psi-4ward/psitransfer/archive/1.3.0.tar.gz
tar -xzvf 1.3.0.tar.gz
cd psitransfer-1.3.0
由于最新版作者没有给我们打好预构建的包,所以这里我们要自己构建一下:
cd app
npm install cross-env
npm install
npm run build
完成之后回到根目录安装项目所需依赖:
cd ..
NODE_ENV=production npm install
可以编辑配置文件设置一个管理员后台密码:
vi config.js
默认是这样的:
"adminPass": false,
改为:
"adminPass": "你的密码"
不过这个后台很鸡肋,只有一个预览上传文件的功能,所以可以跳过。
完成之后新建一个systemd服务文件:
vi /etc/systemd/system/psitransfer.service
写入:
[Unit]
Description=PsiTransfer
After=network.target
[Service]
Type=simple
User=root
Restart=on-failure
Environment=NODE_ENV=production
Environment=PSITRANSFER_PORT=3000
WorkingDirectory=/root/psitransfer-1.3.0
ExecStart=/usr/bin/node app.js
[Install]
WantedBy=multi-user.target
启动psitransfer以及设置开机启动:
systemctl start psitransfer
systemctl enable psitransfer
安装certbot用于签发SSL证书:
yum -y install certbot
使用如下命令签发:
certbot certonly --standalone -d example.com
安装Nginx用于反向代理:
yum -y install nginx
新建一个站点配置文件:
vi /etc/nginx/conf.d/psitransfer.conf
写入:
server {
listen 80;
listen 443 ssl http2;
client_max_body_size 100000m;
server_name example.com;
if ($server_port !~ 443){
rewrite ^(/.*)$ https://$host$1 permanent;
}
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
error_page 497 https://$host$request_uri;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_buffering off;
proxy_redirect off;
proxy_request_buffering off;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
}
启动Nginx以及设置开机启动:
systemctl start nginx
systemctl enable nginx
现在访问你的域名,可以看到这个网盘的主界面:
文件上传:
文件分享: