Skip to content

OneDrive Index目录列表 + 宝塔反代

昨天试了Google Drive 目录列表 – VPS上部署Aria2+Rclone自动移到GoogleDrive+GoIndex/Cloudflare

今天试了试

OneDrive Index

1 – 授权认证,点击这里

  • 授权【国际版、个人版(家庭版)】、【中国版(世纪互联)
    • 国际版:https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=78d4dc35-7e46-42c6-9023-2d39314433a5&response_type=code&redirect_uri=http://localhost/onedrive-login&response_mode=query&scope=offline_access%20User.Read%20Files.ReadWrite.All
    • 中国版:https://login.chinacloudapi.cn/common/oauth2/v2.0/authorize?client_id=dfe36e60-6133-48cf-869f-4d15b8354769&response_type=code&redirect_uri=http://localhost/onedrive-login&response_mode=query&scope=offline_access%20User.Read%20Files.ReadWrite.All
  • 授权后会获取一个localhost开头打不开的链接,这里复制好整个链接地址,包括http://localhost;授权url地址只能用一次,超时需要重新授权。
    • http://localhost/onedrive-login?code=It-is-a-really-long-fcking-code

2 – 下载安装

#新建并进入OneList目录
mkdir /opt/OneList && cd $_
#64位系统下载
wget https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/amd64/linux/OneList    
#给予权限
chmod +x OneList

生成配置

#国际版,将url换成你上面复制的授权地址,包括http://loaclhost。
## /lava 是对应你的这个specific网盘的名称,也是web路径,如果只有一个可以不用写
## 待会也可以在config.json当中改
## 将来就用 https://your-own-domain/lava 来访问这个盘
./OneList -a "http://localhost/onedrive-login?code=It-is-a-really-long-fcking-code" -s "/lava"

#个人版(家庭版)
./OneList -ms -a "url" -s "/onedrive02"

#中国版(世纪互联)
./OneList -cn -a "url" -s "/onedrive03"

提示Success! Add config. '/opt/OneList/config.json'信息,则添加成功。

配置文件路径/opt/OneList/config.json,参数详解,可自行修改

[
  {
    // 如果是家庭版或者个人免费版, 此项应为 true.
    // 我的是国际版
    "MSAccount": true,
    // 如果是中国版(世纪互联), 此项应为 true.
    "MainLand": false,
    // 授权令牌
    "RefreshToken": "1234564567890ABCDEF",
    // 单配置文件中,此项要唯一.将此OneDrive中设置为`RootPath`目录映射在`http://127.0.0.1:5288/onedrive` 下.
    // (只推荐一个盘位的时候使用根目录"/".)
    "SubPath": "/lava",
    // 读取OneDrive的某个目录作为根目录. (比如"/test_dir")
    "RootPath": "/",
    // 隐藏OneDrive目录中的文件夹和文件, 条目间使用 "|" 分割. (跳过缓存设置的条目.)
    "HidePath": "/Test/Obj01|/Test/Obj02",
    // 使用用户名和密码加密OneDrive目录. 目录和用户名密码间使用 "?" 分割, 用户名密码使用 ":" 分割, 条目间使用 "|" 分割. 无效条目将跳过.
    // "AuthPath": "/Test/Auth01?user01:pwd01|/Test/Auth02?user02:pwd02",
    "AuthPath": "/?admin_od:password",
    // 缓存刷新间隔.(所有项目中的刷新时间取最小值为有效刷新间隔)
    "RefreshInterval": 900
  }
]

3 – 运行

# 下载默认的index.html主题 - 很一般,与config.json同目录,即本文默认的
cd /opt/OneList
wget -O indexdefault.html https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/index.html

wget -O indexhao.html
https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/%40Theme/HaorWu/index.html

wget -O indexjack.html https://raw.githubusercontent.com/MoeClub/OneList/master/Rewrite/%40Theme/jackjieYYY/index.html

# 我下的是这个HaorWu主题,看截图 - 不过你想哪个就用哪个
cp indexhao.html index.html

#监听10001地址,自行修改
/opt/OneList/OneList -bind 0.0.0.0 -port 10001

从浏览器输入 http://your-domain-ip:10001/lava (lava是我设置的时候自己取的名字), 然后验证下,admin_od:password,就可以看到效果了。

4 – 开机自启

#将以下代码一起复制到SSH运行

cat > /etc/systemd/system/onelist.service <<EOF
[Unit]
Description=onelist
After=network.target

[Service]
Type=simple
ExecStart=/opt/OneList/OneList -bind 0.0.0.0 -port 10001
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

#启动并设置开机自启
systemctl start onelist
systemctl enable onelist

相关命令

# 启动:
  systemctl start onelist
# 停止:
  systemctl stop onelist
# 重启:
  systemctl restart onelist
# 查看状态:
  systemctl status onelist
# 卸载
#未设置开机自启
  rm -rf /opt/OneList

#设置过开机自启
  systemctl stop onelist
  systemctl disable onelist
  rm -rf /opt/OneList /etc/systemd/system/onelist.service

主要参考:

https://www.moerats.com/archives/1016/#%E6%9B%B4%E6%8D%A2%E4%B8%BB%E9%A2%98

宝塔反代

主要解决两个问题,

  • 用域名而不是ip:port – 暴露IP和Port都不是好事
  • 能用https – 更安全

0- 默认的10001端口之前应该是被放行了,因为通过IP直接访问是需要暴露端口的。

1- 上宝塔,新建一个域名,记得在CloudFlare之类的DNS 管理器上做好解析,现在不能用proxy.

2 – 然后打开SSL – let’s encrypt就挺好用的。“文件验证”最为方便。

3- SSL证书完成之后就可以开启 右上角的 强制HTTPS 功能。然后去CloudFlare见Proxy打开。这样外界就看不到你的网站的真实IP了。更安全。

3- 然后设置“反向代理”

之后就可以用 https://your-own-domain.com/lava 来代替 http://your-domain-ip:10001/lava 来使用 lava这个OneDrive网盘了。

然后就可以在宝塔的“安全”里将10001端口禁止访问了。

Leave a Reply

Your email address will not be published.