I have a back-end service deployed in Kubernetes (at http://purser.default.svc.cluster.local:3030) and a front-end angular 6 application with nginx.conf
as
upstream purser {
server purser.default.svc.cluster.local:3030;
}
server {
listen 4200;
location / {
proxy_pass http://purser;
root /usr/share/nginx/html/appDApp;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
In angular code we are using http.get('http://purser.default.svc.cluster.local:3030', {observe: 'body', responseType: 'json'})
Case1: With proxy_pass
set in nginx.conf
when we hit the ui service it redirects to back-end and gives json
output directly from back-end.
Case2: Without proxy_pass
when we hit front-end service it shows the UI but no data is coming from backend i.e, browser is not able understand http://purser.default.svc.cluster.local:3030