'Using reverse-proxy and nginx for accessing multiple angular application using kubrenetes is not working
i was given a task of configuring kubrenetes for one project(which contains multipe projects under it). The project has already defined docker files and docker-compose files. My task is to migrate from docker compose to kubrenetes. we are using reverse-proxy and also nginx for managing the angular apps.
docker-file of angular app looks like the below
# stage 1
FROM node:14.17.0 as node
WORKDIR /app
COPY package.json package-lock.json /app/
RUN npm install
COPY . .
RUN npm run build-dev
# stage 2
FROM nginx:alpine
WORKDIR /usr/share/nginx/html
RUN rm -rf ./*
COPY --from=node /app/dist/admin .
ENTRYPOINT ["nginx", "-g", "daemon off;"]
proxy.conf looks like this
server{
listen 80;
location /admin/ {
rewrite ^/admin/(.*) /$1 break; # works for both /admin and /admin/
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;
# enable WebSockets (for ws://sockjs not connected error in the client source: https://stackoverflow.com/questions/41381444/websocket-connection-failed-error-during-websocket-handshake-unexpected-respon)
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
proxy_request_buffering off;
proxy_intercept_errors on;
proxy_pass http://admin/admin/;
}
}
i tried to define their respective deployment,service,persistentVolume and persistenVolumeClaim file. But when i try to load the correct url like localhost/admin nginx is retruning 404.
Thank you!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
