惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

A
About on SuperTechFans
Y
Y Combinator Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
Microsoft Security Blog
Microsoft Security Blog
aimingoo的专栏
aimingoo的专栏
I
InfoQ
C
Check Point Blog
IT之家
IT之家
MyScale Blog
MyScale Blog
Apple Machine Learning Research
Apple Machine Learning Research
Vercel News
Vercel News
Last Week in AI
Last Week in AI
GbyAI
GbyAI
P
Proofpoint News Feed
量子位
Stack Overflow Blog
Stack Overflow Blog
Microsoft Azure Blog
Microsoft Azure Blog
月光博客
月光博客
阮一峰的网络日志
阮一峰的网络日志
人人都是产品经理
人人都是产品经理
B
Blog
T
The Blog of Author Tim Ferriss
H
Help Net Security
云风的 BLOG
云风的 BLOG

Rat's Blog - Firefox

Linux VPS使用命令行通过Firefox Send轻松安全地共享文件 - Rat's Blog 火狐插件:百度网盘直接下载+百度云/115右键离线下载 - Rat's Blog Firefox Send:临时文件分享系统,下载1次或24小时后自动删除 - Rat's Blog
使用Firefox Send搭建一个临时文件分享系统 - Rat's Blog
博主: Rat's · 2019-03-21 · via Rat's Blog - Firefox

说明:Firefox Send好像一两年前博主就分享过,是Firefox推出的一個全新的临时文件分享系统,具体查看→传送门,不过貌似代码开源了,也有几个小伙伴搭建的时候遇到了点问题,要博主发个教程,这里就水一下手动搭建和Docker搭建。

截图

请输入图片描述
请输入图片描述
请输入图片描述
请输入图片描述

手动安装

Github地址:https://github.com/mozilla/send

所需环境:Node.js 10+Redis,如果你服务器,特别是CentOS,内存512M或以下的话,建议加点虚拟内存,不然后面可能会安装失败,也可以用下Swap一键脚本→传送门

1、安装Nodejs

#Debian/Ubuntu系统
curl -sL https://deb.nodesource.com/setup_10.x | bash -
apt install -y nodejs git

#CentOS系统
curl -sL https://rpm.nodesource.com/setup_10.x | bash -
yum install nodejs -y
yum -y groupinstall "Development Tools"

2、安装Redis
CenOS 6系统:

#安装EPEL
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
#安装Redis
yum install redis git -y
#启动Redis
service redis start
#设置开机自启
chkconfig redis on

CenOS 7系统:

#安装EPEL
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#安装Redis
yum install redis -y
#启动Redis
systemctl start redis
#设置开机自启
systemctl enable redis

Debian/Ubuntu系统:

apt install redis-server -y

3、安装Firefox Send

git clone https://github.com/mozilla/send.git
cd send
#安装依赖
npm install
#构建生产环境
npm run build
#运行
npm run prod

基本上官方安装方法是这样,不过貌似使用root用户构建生产环境的时候会有点小问题,普通用户倒是没问题的。

一般我们玩的服务器都是直接给的root用户,所以这里就需要新建一个普通用户进行构建操作。

先使用root登录SSH客户端,使用命令:

#新建一个moerats用户,指定该用户的主目录为/home/moerats

#Debian/Ubuntu系统
useradd -d /home/moerats -m moerats

#CentOS系统,以下命令会自动给你创建一个/home/moerats主目录
useradd moerats

然后继续使用命令:

#进入到/home/moerats目录下载send项目
cd /home/moerats
git clone https://github.com/mozilla/send.git
#将send目录用户权限改为新建用户moerats
chown -R moerats:moerats send
#切换moerats用户
su - moerats
#进入项目文件夹
cd send
#安装依赖
npm install
#构建生产环境
npm run build
#运行
npm run prod

不出意外的话,构建和运行都没问题,不过运行的话root用户和新建的moerats用户都是可以运行的。

访问地址为ip:1443,然后一般情况下CentOS还需要开启防火墙1443端口,使用命令:

#CentOS 6
iptables -I INPUT -p tcp --dport 1443 -j ACCEPT
service iptables save
service iptables restart

#CentOS 7
firewall-cmd --zone=public --add-port=1443/tcp --permanent
firewall-cmd --reload

想要访问就需要使用域名反代,方法看后面。

Docker安装

1、安装Docker

#CentOS 6
rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
yum update -y
yum -y install docker-io
service docker start
chkconfig docker on

#CentOS 7、Debian、Ubuntu
curl -sSL https://get.docker.com/ | sh
systemctl start docker
systemctl enable docker

2、拉取镜像
这里就直接使用博主制作的镜像,使用命令:

docker run --name send -d -p 1443:1443 moerats/send

然后使用ip:1443访问即可,如果你想用其它端口,就更改前面的1443参数,比如8888:1443

域名反代

安装Caddy

wget -N --no-check-certificate https://raw.githubusercontent.com/iiiiiii1/doubi/master/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh
#备用地址
wget -N --no-check-certificate https://www.moerats.com/usr/shell/Caddy/caddy_install.sh && chmod +x caddy_install.sh && bash caddy_install.sh

配置Caddy

#以下全部内容是一个整体,请修改域名后一起复制到SSH运行!

#http访问,该配置不会自动签发SSL
echo "www.moerats.com {
 gzip
 proxy / 127.0.0.1:1443 {
    websocket
    header_upstream Host {host}
    header_upstream X-Real-IP {remote}
    header_upstream X-Forwarded-For {remote}
    header_upstream X-Forwarded-Port {server_port}
    header_upstream X-Forwarded-Proto {scheme}
  }
}" > /usr/local/caddy/Caddyfile

#https访问,该配置会自动签发SSL,请提前解析域名到VPS服务器
echo "www.moerats.com {
 gzip
 tls admin@moerats.com
 proxy / 127.0.0.1:1443 {
    websocket
    header_upstream Host {host}
    header_upstream X-Real-IP {remote}
    header_upstream X-Forwarded-For {remote}
    header_upstream X-Forwarded-Port {server_port}
    header_upstream X-Forwarded-Proto {scheme}
  }
}" > /usr/local/caddy/Caddyfile

tls参数会自动帮你签发ssl证书,如果你要使用自己的ssl,改为tls /root/xx.crt /root/xx.key即可。后面为ssl证书路径。

启动Caddy

/etc/init.d/caddy start

就可以打开域名进行访问了。

最后使用啥的就不研究了,有问题可以看下Github文档→传送门


版权声明:本文为原创文章,版权归 Rat's Blog 所有,转载请注明出处!

本文链接:https://www.moerats.com/archives/920/

如教程需要更新,或者相关链接出现404,可以在文章下面评论留言。