Skip to content

Commit 6b23308

Browse files
authored
Added kibana (#2286)
Added kibana to make elastic management easier. PR #1710 did this. PR #1714 revert this. This PR did again and fix some bugs. - [x] Bug Fix (non-breaking change which fixes an issue) - [x] New Feature (non-breaking change which adds functionality)
1 parent 925dd2a commit 6b23308

7 files changed

+68
-24
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ Try our demo at [https://demo.ragflow.io](https://demo.ragflow.io).
192192
* Running on http://x.x.x.x:9380
193193
INFO:werkzeug:Press CTRL+C to quit
194194
```
195-
> If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network anomaly` error because, at that moment, your RAGFlow may not be fully initialized.
195+
> If you skip this confirmation step and directly log in to RAGFlow, your browser may prompt a `network abnormal` error because, at that moment, your RAGFlow may not be fully initialized.
196196
197197
5. In your web browser, enter the IP address of your server and log in to RAGFlow.
198198
> With the default settings, you only need to enter `http://IP_OF_YOUR_MACHINE` (**sans** port number) as the default HTTP serving port `80` can be omitted when using the default configurations.

README_ko.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@
178178
* Running on http://x.x.x.x:9380
179179
INFO:werkzeug:Press CTRL+C to quit
180180
```
181-
> 만약 확인 단계를 건너뛰고 바로 RAGFlow에 로그인하면, RAGFlow가 완전히 초기화되지 않았기 때문에 브라우저에서 `network anomaly` 오류가 발생할 수 있습니다.
181+
> 만약 확인 단계를 건너뛰고 바로 RAGFlow에 로그인하면, RAGFlow가 완전히 초기화되지 않았기 때문에 브라우저에서 `network abnormal` 오류가 발생할 수 있습니다.
182182
183183
5. 웹 브라우저에 서버의 IP 주소를 입력하고 RAGFlow에 로그인하세요.
184184
> 기본 설정을 사용할 경우, `http://IP_OF_YOUR_MACHINE`만 입력하면 됩니다 (포트 번호는 제외). 기본 HTTP 서비스 포트 `80`은 기본 구성으로 사용할 때 생략할 수 있습니다.

README_zh.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
* Running on http://x.x.x.x:9380
168168
INFO:werkzeug:Press CTRL+C to quit
169169
```
170-
> 如果您跳过这一步系统确认步骤就登录 RAGFlow,你的浏览器有可能会提示 `network anomaly``网络异常`,因为 RAGFlow 可能并未完全启动成功。
170+
> 如果您跳过这一步系统确认步骤就登录 RAGFlow,你的浏览器有可能会提示 `network abnormal``网络异常`,因为 RAGFlow 可能并未完全启动成功。
171171
172172
5. 在你的浏览器中输入你的服务器对应的 IP 地址并登录 RAGFlow。
173173
> 上面这个例子中,您只需输入 http://IP_OF_YOUR_MACHINE 即可:未改动过配置则无需输入端口(默认的 HTTP 服务端口 80)。

SECURITY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ main
1818
### Actual behavior
1919

2020
The restricted_loads function at [api/utils/__init__.py#L215](https://github.com/infiniflow/ragflow/blob/main/api/utils/__init__.py#L215) is still vulnerable leading via code execution.
21-
The main reson is that numpy module has a numpy.f2py.diagnose.run_command function directly execute commands, but the restricted_loads function allows users import functions in module numpy.
21+
The main reason is that numpy module has a numpy.f2py.diagnose.run_command function directly execute commands, but the restricted_loads function allows users import functions in module numpy.
2222

2323

2424
### Steps to reproduce

docker/docker-compose-admin-tool.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
include:
2+
- path: ./docker-compose.yml
3+
env_file: ./.env
4+
15
services:
26
kibana:
37
image: kibana:${STACK_VERSION}
@@ -12,7 +16,7 @@ services:
1216
es01:
1317
condition: service_healthy
1418
kibana-user-init:
15-
condition: service_completed_successfully
19+
condition: service_completed_successfully
1620

1721
networks:
1822
- ragflow

docker/entrypoint.sh

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
#!/bin/bash
22

3+
# unset http proxy which maybe set by docker daemon
4+
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
5+
36
/usr/sbin/nginx
47

58
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/

docker/init-kibana.sh

+56-19
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,67 @@
11
#!/bin/bash
22

3-
# 等待 Elasticsearch 啟動
4-
until curl -u "elastic:${ELASTIC_PASSWORD}" -s http://es01:9200 >/dev/null; do
5-
echo "等待 Elasticsearch 啟動..."
6-
sleep 5
7-
done
3+
# unset http proxy which maybe set by docker daemon
4+
export http_proxy=""; export https_proxy=""; export no_proxy=""; export HTTP_PROXY=""; export HTTPS_PROXY=""; export NO_PROXY=""
85

6+
echo "Elasticsearch built-in user: elastic:${ELASTIC_PASSWORD}"
97

10-
echo "使用者: elastic:${ELASTIC_PASSWORD}"
8+
# Wait Elasticsearch be healthy
9+
while true; do
10+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" "http://es01:9200")
11+
exit_code=$?
12+
status=$(echo "$response" | tail -n1)
13+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
14+
echo "Elasticsearch is healthy"
15+
break
16+
else
17+
echo "Elasticsearch is unhealthy: $exit_code $status"
18+
echo "$response"
19+
sleep 5
20+
fi
21+
done
1122

23+
# Create new role with all privileges to all indices
24+
# https://www.elastic.co/guide/en/elasticsearch/reference/current/security-privileges.html#privileges-list-indices
25+
echo "Going to create Elasticsearch role own_indices with all privileges to all indices"
26+
while true; do
27+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" -X POST http://es01:9200/_security/role/own_indices -H 'Content-Type: application/json' -d '{"indices": [{"names": ["*"], "privileges": ["all"]}]}')
28+
exit_code=$?
29+
status=$(echo "$response" | tail -n1)
30+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
31+
echo "Elasticsearch role own_indices created"
32+
break
33+
else
34+
echo "Elasticsearch role own_indices failure: $exit_code $status"
35+
echo "$response"
36+
sleep 5
37+
fi
38+
done
1239

40+
echo "Elasticsearch role own_indices:"
41+
curl -u "elastic:${ELASTIC_PASSWORD}" -X GET "http://es01:9200/_security/role/own_indices"
42+
echo ""
1343

14-
PAYLOAD="{
15-
\"password\" : \"${KIBANA_PASSWORD}\",
16-
\"roles\" : [ \"kibana_admin\",\"kibana_system\" ],
17-
\"full_name\" : \"${KIBANA_USER}\",
18-
\"email\" : \"${KIBANA_USER}@example.com\"
19-
}"
20-
echo "新用戶帳戶: $PAYLOAD"
44+
PAYLOAD="{\"password\": \"${KIBANA_PASSWORD}\", \"roles\": [\"kibana_admin\", \"kibana_system\", \"own_indices\"], \"full_name\": \"${KIBANA_USER}\", \"email\": \"${KIBANA_USER}@example.com\"}"
2145

22-
# 創建新用戶帳戶
23-
curl -X POST "http://es01:9200/_security/user/${KIBANA_USER}" \
24-
-u "elastic:${ELASTIC_PASSWORD}" \
25-
-H "Content-Type: application/json" \
26-
-d "$PAYLOAD"s
46+
echo "Going to create Elasticsearch user ${KIBANA_USER}: ${PAYLOAD}"
47+
48+
# Create new user
49+
while true; do
50+
response=$(curl -s -v -w "\n%{http_code}" -u "elastic:${ELASTIC_PASSWORD}" -X POST http://es01:9200/_security/user/${KIBANA_USER} -H "Content-Type: application/json" -d "${PAYLOAD}")
51+
exit_code=$?
52+
status=$(echo "$response" | tail -n1)
53+
if [ $exit_code -eq 0 ] && [ "$status" = "200" ]; then
54+
echo "Elasticsearch user ${KIBANA_USER} created"
55+
break
56+
else
57+
echo "Elasticsearch user ${KIBANA_USER} failure: $exit_code $status"
58+
echo "$response"
59+
sleep 5
60+
fi
61+
done
2762

28-
echo "新用戶帳戶已創建"
63+
echo "Elasticsearch user ${KIBANA_USER}:"
64+
curl -u "elastic:${ELASTIC_PASSWORD}" -X GET "http://es01:9200/_security/user/${KIBANA_USER}"
65+
echo ""
2966

3067
exit 0

0 commit comments

Comments
 (0)