I have node microservice application running in Kubernetes
I want https://app.domain.com/vehicle/api/v1/.... must go to https://app.domain.com/api/v1/....
if i use rewrite-target annotation as shown below my homepage is coming blank as you can see here
if i remove that annotation then my homepage is coming as expected
this is my ingress yaml file with rewrite annotation
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: ingress-srv
annotations:
kubernetes.io/ingress.class: nginx
nginx.ingress.kubernetes.io/proxy-body-size: "0"
nginx.ingress.kubernetes.io/proxy-connect-timeout: "360"
nginx.ingress.kubernetes.io/proxy-read-timeout: "360"
nginx.ingress.kubernetes.io/proxy-send-timeout: "360"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
tls:
- hosts:
- app.domain.com
secretName: app-ssl
defaultBackend:
service:
name: app-webapp-service
port:
number: 80
rules:
- host: app.domain.com
http:
paths:
- path: /vehicle(/|$)(.*)
pathType: Prefix
backend:
service:
name: app-vehicle-service
port:
number: 5001
- path: /*
pathType: Prefix
backend:
service:
name: app-webapp-service
port:
number: 80
this is my Dockerfile for React (front end), if any changes need to be done please suggest
FROM node:12.18.3 AS build
ENV CI=false
ENV WDS_SOCKET_PORT=0
WORKDIR /app
COPY ["package.json", "package-lock.json", "./"]
RUN npm install --production
COPY . .
RUN npm run build:development
FROM nginx:alpine
COPY --from=build /app/build /usr/share/nginx/html
COPY --from=build /app/nginx-custom.conf /etc/nginx/conf.d/default.conf
this is my nginx-custom.conf
server {
listen 80;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
try_files $uri $uri/ /index.html =404;
}
}
if any changes need to be done in any file please suggest