云服务器、z-file和七牛云Kodo
七牛云Kodo对象存储:https://portal.qiniu.com/developer/user/profile
有10G的永久空间,每个月无限的上传流量和一定的下载流量
七牛云
新建空间

也可以添加其他存储源,z-file管理挺方便的
安装z-file
- 下载安装
1 2 3 4 5 6
| export ZFILE_INSTALL_PATH=~/zfile mkdir -p $ZFILE_INSTALL_PATH && cd $ZFILE_INSTALL_PATH wget <https://c.jun6.net/ZFILE/zfile-release_linux_amd64.tar.gz> tar -xzvf zfile-release_linux_amd64.tar.gz && rm -rf tar zfile-release_linux_amd64.tar.gz chmod +x zfile chmod +x bin/*
|
- 启动
1 2 3 4
| cd ~/zfile/bin ./bin/start.sh 启动中... 目前 PID 为: 4098936
|
1 2
| netstat -tunlp | grep 8080 tcp6 0 0 :::8080 :::* LISTEN 4098936/zfile
|
注意需要在控制台 安全组规则 中放行 8080 端口
- 反向代理
1
| sudo vim /etc/nginx/sites-available/zfile.conf
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
| server { listen 80; server_name your-domain.com;
location / { proxy_pass <http://127.0.0.1:8080>; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; }
location ~* \\.(js|css|png|jpg|jpeg|gif|ico)$ { expires 30d; access_log off; proxy_pass <http://127.0.0.1:8080>; } }
|
启用配置并测试
1 2 3
| sudo ln -s /etc/nginx/sites-available/zfile.conf /etc/nginx/sites-enabled/ sudo nginx -t sudo systemctl restart nginx
|
后面最好配置 HTTPS等
1 2
| sudo apt install -y certbot python3-certbot-nginx sudo certbot --nginx -d your-domain.com
|
访问your-domain.com
就行了(域名备案好麻烦……后来改用海外cdn了)
z-file配置
- 填写站点信息
- 添加存储源
- 选择存储策略为七牛云,填写AccessKey和SecretKey(七牛云密钥管理)
- 其他就是设置管理目录用户组等
参考
使用z-file和七牛云对象存储构建个人网盘 - 简书
通过使用Cloudflare免费CDN隐藏服务器的ip,防止网站被DDOS攻击