-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathipfs-cluster的基本认证配置
50 lines (45 loc) · 2.06 KB
/
ipfs-cluster的基本认证配置
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
参考 https://github.com/ipfs/ipfs-cluster/blob/master/sharness/config/basic_auth/service.json 对配置文件进行修改
命令修改方法
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods '["PUT", "GET", "POST", "OPTIONS"]'
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin '["*"]'
windows下操作需要转移 \
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"http://example.com\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Credentials "[\"true\"]"
$ ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\", \"GET\"]"
修改ipfs-cluster配置文件
cd ~/.ipfs-cluster
vi service.json
修改 restapi 部分
"restapi": {
"ssl_cert_file": "",
"ssl_key_file": "",
"http_listen_multiaddress": "/ip4/0.0.0.0/tcp/9094", 配置为0.0.0.0 表示可接受所有网络访问
"read_timeout": "30s",
"read_header_timeout": "5s",
"write_timeout": "1m0s",
"idle_timeout": "2m0s",
"basic_auth_credentials": { 用户名密码填写位置
"testuser": "testpass", 用户名对应的密码
"userwithoutpass": ""
},
"cors_allowed_origins": [
"*"
],
"cors_allowed_methods": [
"GET","POST","DELETE" restapi接受的方法限制
],
"cors_allowed_headers": [],
"cors_exposed_headers": [
"Content-Type",
"X-Stream-Output",
"X-Chunked-Output",
"X-Content-Length"
],
"cors_allow_credentials": true,
"cors_max_age": "0s"
}
配置完成后需要用下面命令完成集群管理
ipfs-cluster-ctl --basic-auth "testuser:testpass" --force-http add -w service.json.bak20190402
restapi调用也可用curl完成
curl --basic --user testuser:testpass http://10.180.11.221:9094/id
curl --basic --user testuser:testpass http://10.180.11.221:9094/add -F "file=@/tmp/abc3.txt" 上传文件