Skip to content

Commit

Permalink
Add dataprep endpoint in nginx microservice (opea-project#795)
Browse files Browse the repository at this point in the history
Signed-off-by: lvliang-intel <liang1.lv@intel.com>
  • Loading branch information
lvliang-intel authored Oct 16, 2024
1 parent c6dfeb0 commit 2f0d78e
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions comps/nginx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ ENV FRONTEND_SERVICE_PORT=5173
ENV BACKEND_SERVICE_NAME=chatqna
ENV BACKEND_SERVICE_IP=localhost
ENV BACKEND_SERVICE_PORT=8888
ENV DATAPREP_SERVICE_IP=localhost
ENV DATAPREP_SERVICE_PORT=6007

COPY comps/nginx/start-nginx.sh /usr/local/bin/start-nginx.sh
RUN chmod +x /usr/local/bin/start-nginx.sh
Expand Down
4 changes: 4 additions & 0 deletions comps/nginx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export FRONTEND_SERVICE_PORT=5173
export BACKEND_SERVICE_NAME=chatqna
export BACKEND_SERVICE_IP=${your_backend_service_ip}
export BACKEND_SERVICE_PORT=8888
export DATAPREP_SERVICE_IP=${your_dataprep_service_ip}
export DATAPREP_SERVICE_PORT=6007
export NGINX_PORT=${your_nginx_port}
```

Expand Down Expand Up @@ -53,6 +55,8 @@ docker run -d --name opea-nginx -p ${NGINX_PORT}:80 \
-e BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME} \
-e BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP} \
-e BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT} \
-e DATAPREP_SERVICE_IP=${DATAPREP_SERVICE_IP} \
-e DATAPREP_SERVICE_PORT=${DATAPREP_SERVICE_PORT} \
opea/nginx:latest
```

Expand Down
2 changes: 2 additions & 0 deletions comps/nginx/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ services:
- BACKEND_SERVICE_NAME=${BACKEND_SERVICE_NAME}
- BACKEND_SERVICE_IP=${BACKEND_SERVICE_IP}
- BACKEND_SERVICE_PORT=${BACKEND_SERVICE_PORT}
- DATAPREP_SERVICE_IP=${DATAPREP_SERVICE_IP}
- DATAPREP_SERVICE_PORT=${DATAPREP_SERVICE_PORT}
ipc: host
restart: always

Expand Down
24 changes: 24 additions & 0 deletions comps/nginx/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,28 @@ server {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /v1/dataprep {
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /v1/dataprep/get_file {
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}

location /v1/dataprep/delete_file {
proxy_pass http://${DATAPREP_SERVICE_IP}:${DATAPREP_SERVICE_PORT};
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
2 changes: 1 addition & 1 deletion comps/nginx/start-nginx.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
# SPDX-License-Identifier: Apache-2.0

#!/bin/sh
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
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
nginx -g 'daemon off;'

0 comments on commit 2f0d78e

Please sign in to comment.