搭建个人5T网盘(OneindexN+OneDrive)

搭建个人5T网盘(OneindexN+OneDrive)

Demo:cloud.ffing.cn

使用motrix下载工具,满速下载香,真香!

https://cloud.ffing.cn/0-%E8%AF%B7%E4%BD%BF%E7%94%A8Motrix%E5%B7%A5%E5%85%B7%E4%B8%8B%E8%BD%BD%E6%96%87%E4%BB%B6%EF%BC%8C%E5%90%A6%E5%88%99%E5%AE%B9%E6%98%93%E4%B8%8B%E8%BD%BD%E5%A4%B1%E8%B4%A5%20%5B%E5%AE%89%E8%A3%85%E5%8C%85%E5%8F%8A%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B%5D-0/Motrix%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B.gif

因为牵涉内容较多,篇幅较长。

oneindex作者已经删库,这里我以OneindexN稍做修改作为我的前端。

当个网盘、图床都可以,尽量不要当电影库,避免被封。

优势:

  • oneindex 不走服务器流量,直连国内世纪互联数据中心
  • 满速下载(速度优于国产网盘)
  • 空间1-5 T , 自定义页面,可玩性大
  • 微软官方解释:
    我们为中国用户提供了 Office 365 全球版和 Office 365 中国版两种版本。主要区别在于: Office 365 中国版由世纪互联负责运营,数据中心位于北京、上海,可以提供增值税发票。 目前仅 Office 365 全球版提供 Yammer、Microsoft Planner、Microsoft Teams 以及 Sway 等产品。

准备工作:

  • 微软账号
  • 手机号
  • 科学上网
  • 云服务器(nginx+php5.6以上)

流程:

  • onedrive business 账号 (订阅office开发者E5账号) 
  • onedrive(调整5T空间)
  • 创建OneDriveAPP
  • 部署OneindexN程序(前端,利用OneDrive的API,列出OneDrive目录)
  • 安装aria2并配置自动上传至onedrive
  • 测试
  • E5账户续约
  • 其他

第一步:onedrive business 账号

通过微软账号,订阅office开发者E5权益,获取onedrive business 账号(需要科学上网否则无法获取手机验证码

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-28.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

国内office开发者:https://developer.microsoft.com/zh-cn/microsoft-365/dev-program

或百度搜索:“office开发人员计划”

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-30.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-31.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-33.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-34.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-35.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-36.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-37.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###创建onedrive business 账号

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-38.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###需要科学上网,否则无法收到验证码

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-39.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-40.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-41.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

#onedrive business 账号创建完成

注:3个月有效期,到期手工续订,或者利用api的频繁使用自动续订

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-42.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

第二步,调整onedrive空间(默认1T,调整为5T)

Onedirve空间管理:https://admin.onedrive.com/#v=StorageSettings

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-43-1024x769.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-44-1024x705.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-45-1024x612.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-46-1024x669.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-47-1024x635.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

第三步,创建OneDriveAPP

国际 Azure:https://portal.azure.com/

国内世纪互联:https://portal.azure.cn

因是E5权益账号,需打开国际 Azure:https://portal.azure.com/

需要获取APPID、APP秘钥,配置API权限

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-48-1024x447.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-49-1024x580.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-50-1024x556.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-53-1024x831.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###复制获取到APPID进行保存,一会要用到。

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-54.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###创建秘钥,秘钥只会出现一次,必须保存好,一会要用到。

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-56-1024x822.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-57-1024x550.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###添加api权限

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-58-1024x706.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-59-1024x568.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

OK,刚创建的app统计信息

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-63.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

第四步,部署OneindexN

服务器需nginx+php5.6以上,如没环境可使用我的脚本进行环境搭建。

一键脚本:bash <(curl https://gitee.com/ffing/onekey/raw/master/onekey.sh)

1.克隆OneindexN前端到指定目录

我的gitee项目地址:https://gitee.com/ffing/oneindexn.git

#懒人,直接git到nginx站点目录
git clone https://gitee.com/ffing/oneindexn.git /usr/share/nginx/oneindexn

2.对OneindexN目录进行授权

chown -R apache:apache /usr/share/nginx/oneindexn

3.配置nginx

新增oneindexn配置文件

vim /etc/nginx/conf.d/oneindex.conf

oneindex.conf内容如下:(请更改自己域名、oneindexn路径、证书路径)

server {
listen 80;
server_name cloud.ffing.cn;
rewrite ^(.*)$ https://$host$1 permanent;
}
server {
listen 443 ssl;
server_name cloud.ffing.cn;
root /usr/share/nginx/oneindexn;
index index.php;

#ssl证书(修改为自己证书路径)
ssl_certificate /opt/cert/cloud.ffing.cn.pem;
ssl_certificate_key /opt/cert/cloud.ffing.cn.key;
ssl_protocols 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;

#去除地址栏?,伪静态
location / {
        if (!-f $request_filename){
                set $rule_0 1$rule_0;
                         }
        if (!-d $request_filename){
                 set $rule_0 2$rule_0;
                         }
        if ($rule_0 = "21"){
                 rewrite ^/(.*) /?/$1 last;
                         }
}

#aria2 反代
location /jsonrpc {
        proxy_pass http://localhost:6800/jsonrpc;
        proxy_redirect off;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For
        $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        }

#PHP
location ~ \.php$        {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include        fastcgi_params;
                        }


}

4.配置完成后重启nginx

systemctl restart nginx

5.浏览器打开oneindexn前端,进行配置

我在nginx中配置的域名:cloud.ffing.cn

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-51-1024x486.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###输入我们上面获取的appid和秘钥

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-64-1024x715.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

###绑定我的business账号ffingcn@ffingcn.onmicrosoft(如果刚清除过浏览器缓存或者不在同个浏览器,则需要我们重新绑定刚申请的business账号)

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-62-1024x351.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

OK,部署结束。

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-65-1024x414.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

后台内容自行修改

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-66-1024x503.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-67-1024x868.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

第五步,安装aria2并配置自动上传至onedrive

实现效果:通过yaaw面板下载完成的文件自动上传至onedrive

可以自行安装aria2也可以使用我的一键脚本。

一键脚本:bash <(curl https://gitee.com/ffing/onekey/raw/master/onekey.sh)

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-68.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

检查aria2配置/etc/aria2/aria2.conf,最后是否添加上传脚本

#上传配置(上传脚本路径,我默认放置在oneindxn中)
on-download-complete=/usr/share/nginx/oneindexn/onedirver_upload.sh

检查上传脚本,/usr/share/nginx/oneindexn/onedirver_upload.sh

onedrive上传脚本,脚本内容如下:(标准颜色路径自行修改)

#!/bin/bash

###根据自己情况修改###

#Onedirve上传目录(在web上onedrive显示的目录和本地没关系)
UPpath='/Yaaw_Upload'
#Yaaw下载目录
DOWNpath='/aria2_download'
#PHP路径
PHPpath='/bin/php'
#oneindexn路径
ONEpath='/usr/share/nginx/oneindexn'


###无需修改###
path=$3
if [ $2 -eq 0 ]
        then
                exit 0
fi
while true; do
filepath=$path
path=${path%/*};
if [ "$path" = "$DOWNpath" ] && [ $2 -eq 1 ]
    #如果下载的是单个文件
    then
    $PHPpath "$ONEpath"/one.php upload:file "$filepath" "$UPpath"/
    rm -rf "$filepath"
    exit 0
elif [ "$path" = "$DOWNpath" ]
    #下载的是文件夹
    then
    $PHPpath "$ONEpath"/one.php upload:folder "$filepath"/ "$UPpath"/"${filepath##*/}"/
    rm -rf "$filepath"/
    exit 0
fi
done

添加执行权限

chmod +x /usr/share/nginx/oneindexn/onedirver_upload.sh

第六步,测试

本地onedrive上传文件,测试oneindex前端

yaaw远程下载,测试oneindex前端及本地onedrive客户端

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-79.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-69-1024x789.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0
https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-70-1024x785.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

E5账户续约

a,绑定github账户,通过github的活动来增加微软账户的活跃度

如果你经常登陆github是个不错的选择

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-77.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

b,通过大神开发的api模拟开发者动作

outlook的api模拟开发者:https://e5.qyi.io/

xxx@xxx.onmicrosoft.com建个子账号做outlookapi的账号

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-78.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

其他:

1.onedrive business 账号,通过oneindexn列表前端无法删除目录,可以通过office.com进入onedrive删除(客户端删除文件会有个先下载到本地、再删除、最后同步云端流程。。。尤其是大文件)

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-80.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

2.修改 oneindexn前端程序验证地址

编辑文件:oneindexn/controller/AdminController.php

将我的云盘地址cloud.ffing.cn,替换为你自己搭建地址

https://qnimg.ffing.cn/wp-content/uploads/2021/08/image-81.png?imageView2/0/q/75|watermark/1/image/aHR0cHM6Ly9xbmltZy5mZmluZy5jbi9mbl9sb2dvLnBuZw==/dissolve/55/gravity/SouthEast/dx/0/dy/0

3.修改oneindexn前端主题以nexmoe为例

编辑文件:oneindexn/view/themes/nexmoe/layout.php

good good study, day day up!

发表评论

textsms
account_circle
email

搭建个人5T网盘(OneindexN+OneDrive)
Demo:cloud.ffing.cn 使用motrix下载工具,满速下载香,真香! 因为牵涉内容较多,篇幅较长。 oneindex作者已经删库,这里我以OneindexN稍做修改作为我的前端。 当个网…
扫描二维码继续阅读
2021-08-15