Skip to content

Commit 9a863ca

Browse files
author
ganesanintel
authored
Use nginx proxy instead of HOST_IP (open-edge-platform#138)
1 parent 2576348 commit 9a863ca

File tree

10 files changed

+119
-20
lines changed

10 files changed

+119
-20
lines changed

sample-applications/chat-question-and-answer-core/docker/compose.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
services:
2+
nginx:
3+
image: nginx:latest
4+
ports:
5+
- "8102:80"
6+
volumes:
7+
- ../nginx.conf:/etc/nginx/nginx.conf:ro
8+
depends_on:
9+
- chatqna-core
10+
- chatqna-core-ui
211
chatqna-core:
312
image: ${REGISTRY:-}chatqna:${BACKEND_TAG:-latest}
413
profiles:

sample-applications/chat-question-and-answer-core/docs/user-guide/deploy-with-helm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ kubectl get pods -n <your-namespace>
115115
kubectl get services -n <your-namespace>
116116
```
117117

118-
### Step 7: Retrieving the Service Endpoint (NodePort and NodeIP)
118+
### Step 7: Access the Application
119119

120120
Open the UI in a browser at http://\<node-ip\>:\<ui-node-port\>
121121

sample-applications/chat-question-and-answer-core/docs/user-guide/get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ By following this guide, you will learn how to:
101101
```
102102

103103
7. **Access the Application**:
104-
Open a browser and go to `http://<host-ip>:5173` to access the application dashboard. The application dashboard allows the user to,
104+
Open a browser and go to `http://<host-ip>:8102` to access the application dashboard. The application dashboard allows the user to,
105105
- Create and manage context by adding documents (pdf, docx, etc. Note: Web links are not supported for the Core version of the sample application. Note: There are restrictions on the max size of the document allowed.
106106
- Start Q&A session with the created context.
107107

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
events {}
2+
3+
http {
4+
server {
5+
listen 80;
6+
listen [::]:80;
7+
8+
client_max_body_size 500M;
9+
proxy_read_timeout 300;
10+
proxy_connect_timeout 300;
11+
proxy_send_timeout 300;
12+
13+
location / {
14+
proxy_pass http://chatqna-core-ui:80;
15+
proxy_http_version 1.1;
16+
proxy_set_header Upgrade $http_upgrade;
17+
proxy_set_header Connection "Upgrade";
18+
proxy_set_header Host $host;
19+
proxy_set_header X-Real-IP $remote_addr;
20+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21+
proxy_set_header X-Forwarded-Proto $scheme;
22+
proxy_cache_bypass $http_upgrade;
23+
}
24+
25+
location /v1/chatqna {
26+
proxy_pass http://chatqna-core:8888;
27+
proxy_http_version 1.1;
28+
proxy_set_header Upgrade $http_upgrade;
29+
proxy_set_header Connection "Upgrade";
30+
proxy_set_header Host $host;
31+
proxy_set_header X-Real-IP $remote_addr;
32+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33+
proxy_set_header X-Forwarded-Proto $scheme;
34+
proxy_cache_bypass $http_upgrade;
35+
}
36+
37+
}
38+
}

sample-applications/chat-question-and-answer-core/scripts/setup_env.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ else
6868
mkdir "$MODEL_CACHE_PATH"
6969
fi
7070

71+
72+
# Export environment variables
7173
# Set COMPOSE_PROFILES based on device argument
7274
# If device is GPU, check if render device exists
7375
# If it exists, set to GPU-DEVICE
@@ -86,8 +88,6 @@ if [ "$DEVICE" == "GPU" ]; then
8688
fi
8789
fi
8890

89-
# Export other environment variables
90-
export HOST_IP=$(hostname -I | awk '{print $1}')
9191
export GID=$(id -g ${USER})
9292
export HF_ACCESS_TOKEN="${HUGGINGFACEHUB_API_TOKEN}"
9393
export EMBEDDING_MODEL_ID="BAAI/bge-small-en-v1.5"
@@ -97,5 +97,6 @@ export EMBEDDING_DEVICE="${DEVICE}"
9797
export RERANKER_DEVICE="${DEVICE}"
9898
export LLM_DEVICE="${DEVICE}"
9999
export MODEL_CACHE_PATH="$MODEL_CACHE_PATH"
100-
export APP_BACKEND_URL="http://$HOST_IP:8888"
100+
101+
export APP_BACKEND_URL="/v1/chatqna"
101102
export COMPOSE_PROFILES=$PROFILES

sample-applications/chat-question-and-answer/docker-compose.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
services:
2+
nginx:
3+
image: nginx:latest
4+
ports:
5+
- "8101:80"
6+
volumes:
7+
- ./nginx.conf:/etc/nginx/nginx.conf:ro
8+
depends_on:
9+
- chatqna
10+
- chatqna-ui
11+
- dataprep_pgvector
12+
networks:
13+
- my_network
214
chatqna:
315
image: ${BE_IMAGE_NAME}
416
build:
@@ -96,7 +108,7 @@ services:
96108

97109
chatqna-ui:
98110
image: ${FE_IMAGE_NAME}
99-
container_name: chatqna-ui_server
111+
container_name: chatqna-ui
100112
build:
101113
context: ./ui/react/
102114
ports:

sample-applications/chat-question-and-answer/docs/user-guide/deploy-with-helm.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ kubectl get pods -n <your-namespace>
139139
kubectl get services -n <your-namespace>
140140
```
141141

142-
### Step 7: Retrieving the Service Endpoint (NodePort and NodeIP)
142+
### Step 7: Access the Application
143143

144144
Open the UI in a browser at http://\<node-ip\>:\<ui-node-port\>
145145

sample-applications/chat-question-and-answer/docs/user-guide/get-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ Visit https://huggingface.co/settings/tokens to get your token.
147147
```
148148

149149
6. **Access the Application**:
150-
Open a browser and go to `http://<host-ip>:5173` to access the application dashboard. The application dashboard allows the user to,
150+
Open a browser and go to `http://<host-ip>:8101` to access the application dashboard. The application dashboard allows the user to,
151151
- Create and manage context by adding documents (pdf, docx, etc.) and web links. Note: There are restrictions on the max size of the document allowed.
152152
- Start Q&A session with the created context.
153153

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
events {}
2+
3+
http {
4+
server {
5+
listen 80;
6+
listen [::]:80;
7+
8+
client_max_body_size 500M;
9+
proxy_read_timeout 300;
10+
proxy_connect_timeout 300;
11+
proxy_send_timeout 300;
12+
13+
location / {
14+
proxy_pass http://chatqna-ui:80;
15+
proxy_http_version 1.1;
16+
proxy_set_header Upgrade $http_upgrade;
17+
proxy_set_header Connection "Upgrade";
18+
proxy_set_header Host $host;
19+
proxy_set_header X-Real-IP $remote_addr;
20+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
21+
proxy_set_header X-Forwarded-Proto $scheme;
22+
proxy_cache_bypass $http_upgrade;
23+
}
24+
25+
location /v1/chatqna {
26+
proxy_pass http://chatqna:8080;
27+
proxy_http_version 1.1;
28+
proxy_set_header Upgrade $http_upgrade;
29+
proxy_set_header Connection "Upgrade";
30+
proxy_set_header Host $host;
31+
proxy_set_header X-Real-IP $remote_addr;
32+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
33+
proxy_set_header X-Forwarded-Proto $scheme;
34+
proxy_cache_bypass $http_upgrade;
35+
}
36+
37+
location /v1/dataprep {
38+
proxy_pass http://dataprep_pgvector:8000;
39+
proxy_http_version 1.1;
40+
proxy_set_header Upgrade $http_upgrade;
41+
proxy_set_header Connection "Upgrade";
42+
proxy_set_header Host $host;
43+
proxy_set_header X-Real-IP $remote_addr;
44+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
45+
proxy_set_header X-Forwarded-Proto $scheme;
46+
proxy_cache_bypass $http_upgrade;
47+
}
48+
}
49+
}

sample-applications/chat-question-and-answer/setup.sh

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,10 @@ export INDEX_NAME=intel-rag
1111

1212
#Embedding service required configurations
1313
export EMBEDDING_ENDPOINT_URL=http://tei-embedding-service
14-
#Setup the host IP
15-
export HOST_IP=$(hostname -I | awk '{print $1}')
16-
# The above command does not work on EMT. Two options:
17-
# 1. Check with:
18-
# ip -o route get to 8.8.8.8 | sed -n 's/.*src \([0-9.]\+\).*/\1/p'
19-
# But this approach could also have an issue based on kind of
20-
# deployment (airgapped or not). Need to check for a better solution.
21-
# IP address of 8.8.8.8 is Google address.
22-
# 2. Eliminate the need for hostname.
2314

2415
# UI ENV variables
25-
export APP_ENDPOINT_URL=http://$HOST_IP:8100
26-
export APP_DATA_PREP_URL=http://$HOST_IP:8000
16+
export APP_ENDPOINT_URL=/v1/chatqna
17+
export APP_DATA_PREP_URL=/v1/dataprep
2718

2819
# Required environment variables for the ChatQnA backend
2920
export CHUNK_SIZE=1500
@@ -32,7 +23,6 @@ export FETCH_K=10
3223
export BATCH_SIZE=32
3324

3425
# Env variables for DataStore
35-
export DATASTORE_HOST=$HOST_IP
3626
export DATASTORE_HOST_PORT=8200
3727
export DATASTORE_ENDPOINT_URL=http://data-store:8000
3828

0 commit comments

Comments
 (0)