I'm trying to learn K8. I have a frontend app that is made using angular. I'm serving it behind an NGINX proxy. I also have a backend that has functionalities. There are my files,
nginx.conf
http {
upstream gateway {
server sb-gateway:8081;
}
include /etc/nginx/mime.types;
server {
listen 80;
sendfile on;
default_type application/octet-stream;
location / {
root /usr/share/nginx/html;
try_files $uri $uri/ /index.html;
index index.html index.htm;
}
location /api/ {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://gateway;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
}
user.service.ts
...
return this.http.post('/api/login', {data})
...
ui-service.yaml
apiVersion: v1
kind: Service
metadata:
labels:
app: sb-ui
name: sb-ui
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: 80
nodePort: 30000
selector:
app: sb-ui
The backend service is called sb-gateway
and I'm trying to route all requests that have /api/
in them to the backend (as specified in NGINX). But I get this error when i try to hit a route from the frontend/pressing a button.
POST http://192.168.64.2:30000/api/login 404 (NOT FOUND)
.
I'm trying to run this on minikube. I have SSH'd in the frontend pod and tried to curl the backend service. It works. I just need to figure out how am I supposed to communicated from the frontend service to the backend service on angular.
Any help would be greatly appreciated!