Goindex安装使用

两种部署方式

GoIndex支持两种安装部署方案:推荐第二种比较简单

安装部署方案1,此方案适合动手能力比较强,对安全性要求高的同学使用。

  1. 在本地安装 rclone。
  2. 按照 https://rclone.org/drive/ 流程进行授权。
  3. 执行 rclone config file 查看 rclone.conf 路径。找到root_folder_id和refresh_token记录下来。
  4. 下载 https://github.com/imgyh/goindex-backup https://github.com/donwa/goindex 中的 index.js 并填入 root 和 refresh_token
  5. 复制代码 到 CloudFlare 部署。

安装部署方案2。作者不会记录refresh_token,但为避免纠纷,建议有条件的同学使用方案1进行部署

  1. 访问:https://install.gd.workers.dev/
  2. 授权认证后,生成部署代码。
  3. 复制代码 到 CloudFlare 部署。

由于goindex的作者删库了,所以复制的代码需要修改,可以使用我修改好的index.js仓库地址

点击你的硬盘,最后的ID就是所需要填写的目录ID

部署到cloudflare wokers

首先登录cloudflare,官网→传送门,然后看到Workers入口。

接下来点击Create a Worker创建一个Worker

把你之前获取的Workers代码粘贴进去,然后可以在左上角双击修改域名,再点击Save and Deploy即可。

最后打开分配的子域名即可,此后修改配置可以自行修改Workers代码

API部署

这里也可以使用自己的API部署,好处就是安全点,高峰期也不容易爆炸,当然安装会麻烦点,如果不经常使用的话,还是建议用上面的方法快速部署。

1、获取GDrive客户端

先启用Google Drive API,启用地址:点击进入,注意这里使用个人账号操作。

再创建一个OAuth client ID,创建地址:点击进入。应用类型选择其他(Other),名称自己填,这里博主填的GoIndex

然后你会获得自己的客户端ID和客户端密钥,再复制下来。

2、获取refresh_token

这里使用Rclone来获取refresh_token,先登录VPS,再安装Rclone,使用命令:

1
curl https://rclone.org/install.sh | bash

开始配置,使用命令:

1
rclone config

会出现以下信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> Rats #配置名称,随便填
Type of storage to configure.
Enter a string value. Press Enter for the default ("").
Choose a number from below, or type in your own value
1 / 1Fichier
\ "fichier"
2 / Alias for an existing remote
\ "alias"
3 / Amazon Drive
\ "amazon cloud drive"
4 / Amazon S3 Compliant Storage Provider (AWS, Alibaba, Ceph, Digital Ocean, Dreamhost, IBM COS, Minio, etc)
\ "s3"
5 / Backblaze B2
\ "b2"
6 / Box
\ "box"
7 / Cache a remote
\ "cache"
8 / Dropbox
\ "dropbox"
9 / Encrypt/Decrypt a remote
\ "crypt"
10 / FTP Connection
\ "ftp"
11 / Google Cloud Storage (this is not Google Drive)
\ "google cloud storage"
12 / Google Drive
\ "drive"
13 / Google Photos
\ "google photos"
14 / Hubic
\ "hubic"
15 / JottaCloud
\ "jottacloud"
16 / Koofr
\ "koofr"
17 / Local Disk
\ "local"
18 / Mega
\ "mega"
19 / Microsoft Azure Blob Storage
\ "azureblob"
20 / Microsoft OneDrive
\ "onedrive"
21 / OpenDrive
\ "opendrive"
22 / Openstack Swift (Rackspace Cloud Files, Memset Memstore, OVH)
\ "swift"
23 / Pcloud
\ "pcloud"
24 / Put.io
\ "putio"
25 / QingCloud Object Storage
\ "qingstor"
26 / SSH/SFTP Connection
\ "sftp"
27 / Union merges the contents of several remotes
\ "union"
28 / Webdav
\ "webdav"
29 / Yandex Disk
\ "yandex"
30 / http Connection
\ "http"
31 / premiumize.me
\ "premiumizeme"
Storage> 12 #选择12,Google Drive
client_id> 850428 #填上你的Google Drive客户端ID
client_secret> D72gPc #填上你的Google Drive客户端密匙
Choose a number from below, or type in your own value
1 / Full access all files, excluding Application Data Folder.
\ "drive"
2 / Read-only access to file metadata and file contents.
\ "drive.readonly"
/ Access to files created by rclone only.
3 | These are visible in the drive website.
| File authorization is revoked when the user deauthorizes the app.
\ "drive.file"
/ Allows read and write access to the Application Data folder.
4 | This is not visible in the drive website.
\ "drive.appfolder"
/ Allows read-only access to file metadata but
5 | does not allow any access to read or download file content.
\ "drive.metadata.readonly"
scope> 1
ID of the root folder
Leave blank normally.
Fill in to access "Computers" folders. (see docs).
Enter a string value. Press Enter for the default ("").
root_folder_id> #回车
Service Account Credentials JSON file path
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Enter a string value. Press Enter for the default ("").
service_account_file> #回车
Edit advanced config? (y/n)
y) Yes
n) No
y/n> n #输入n
Remote config
Use auto config?
* Say Y if not sure
* Say N if you are working on a remote or headless machine
y) Yes
n) No
y/n> n #输入n
If your browser doesn't open automatically go to the following link: https://accounts.google.com/o/ #打开该地址获取code
Log in and authorize rclone for access
Enter verification code>hjdd #输入你获取到的code
Configure this as a team drive?
y) Yes
n) No
y/n> n #输入n
--------------------
[Rats]
type = drive
client_id = 85042871
client_secret = D72gPc
scope = drive
token = {"access_token":"y902Z"} #记住里面的refresh_token参数
--------------------
y) Yes this is OK
e) Edit this remote
d) Delete this remote
y/e/d> y #输入y
Current remotes:

Name Type
==== ====
Rats drive

e) Edit existing remote
n) New remote
d) Delete remote
r) Rename remote
c) Copy remote
s) Set configuration password
q) Quit config
e/n/d/r/c/s/q> q #输入q保存退出

此时我们在配置过程中就获取到了refresh_token参数,如果忘了的可以查看配置文件。

不知道配置文件在哪的,可以使用命令:

1
rclone config file | grep rclone.conf

3、修改Workers代码

1
2
3
4
#填上自己的api客户端,密匙和获取到的refresh_token
“client_id”:“20226481”,
“client_secret”:“X4Z3ca8”,
refresh_token”:“”,

最后就可以部署Workers代码了,方法参考上面的快速部署。