Skip to content

Commit 2f0d78e

Browse files
Add dataprep endpoint in nginx microservice (opea-project#795)
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
1 parent c6dfeb0 commit 2f0d78e

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

comps/nginx/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ ENV FRONTEND_SERVICE_PORT=5173
1313
ENV BACKEND_SERVICE_NAME=chatqna
1414
ENV BACKEND_SERVICE_IP=localhost
1515
ENV BACKEND_SERVICE_PORT=8888
16+
ENV DATAPREP_SERVICE_IP=localhost
17+
ENV DATAPREP_SERVICE_PORT=6007
1618

1719
COPY comps/nginx/start-nginx.sh /usr/local/bin/start-nginx.sh
1820
RUN chmod +x /usr/local/bin/start-nginx.sh

comps/nginx/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export FRONTEND_SERVICE_PORT=5173
2323
export BACKEND_SERVICE_NAME=chatqna
2424
export BACKEND_SERVICE_IP=${your_backend_service_ip}
2525
export BACKEND_SERVICE_PORT=8888
26+
export DATAPREP_SERVICE_IP=${your_dataprep_service_ip}
27+
export DATAPREP_SERVICE_PORT=6007
2628
export NGINX_PORT=${your_nginx_port}
2729
```
2830

@@ -53,6 +55,8 @@ docker run -d --name opea-nginx -p ${NGINX_PORT}:80 \
5355
-e BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME} \
5456
-e BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP} \
5557
-e BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT} \
58+
-e DATAPREP_SERVICE_IP=${DATAPREP_SERVICE_IP} \
59+
-e DATAPREP_SERVICE_PORT=${DATAPREP_SERVICE_PORT} \
5660
opea/nginx:latest
5761
```
5862

comps/nginx/docker-compose.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ services:
1616
- BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
1717
- BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
1818
- BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
19+
- DATAPREP_SERVICE_IP=${DATAPREP_SERVICE_IP}
20+
- DATAPREP_SERVICE_PORT=${DATAPREP_SERVICE_PORT}
1921
ipc: host
2022
restart: always
2123

comps/nginx/nginx.conf.template

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,28 @@ server {
2525
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
2626
proxy_set_header X-Forwarded-Proto $scheme;
2727
}
28+
29+
location /v1/dataprep {
30+
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
31+
proxy_set_header Host $host;
32+
proxy_set_header X-Real-IP $remote_addr;
33+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
34+
proxy_set_header X-Forwarded-Proto $scheme;
35+
}
36+
37+
location /v1/dataprep/get_file {
38+
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
39+
proxy_set_header Host $host;
40+
proxy_set_header X-Real-IP $remote_addr;
41+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
42+
proxy_set_header X-Forwarded-Proto $scheme;
43+
}
44+
45+
location /v1/dataprep/delete_file {
46+
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
47+
proxy_set_header Host $host;
48+
proxy_set_header X-Real-IP $remote_addr;
49+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
50+
proxy_set_header X-Forwarded-Proto $scheme;
51+
}
2852
}

comps/nginx/start-nginx.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# SPDX-License-Identifier: Apache-2.0
33

44
#!/bin/sh
5-
envsubst '${FRONTEND_SERVICE_IP} ${FRONTEND_SERVICE_PORT} ${BACKEND_SERVICE_NAME} ${BACKEND_SERVICE_IP} ${BACKEND_SERVICE_PORT}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf
5+
envsubst '${FRONTEND_SERVICE_IP} ${FRONTEND_SERVICE_PORT} ${BACKEND_SERVICE_NAME} ${BACKEND_SERVICE_IP} ${BACKEND_SERVICE_PORT} ${DATAPREP_SERVICE_IP} ${DATAPREP_SERVICE_PORT}' < /etc/nginx/nginx.conf.template > /etc/nginx/conf.d/default.conf
66
nginx -g 'daemon off;'

0 commit comments

Comments
 (0)