I have 2 angular app bundled in 2 separate docker images based on nginx image:
FROM node:14-alpine as build
WORKDIR /app
RUN npm install -g @angular/cli
COPY FrontEnd1/package*.json ./
RUN npm install
COPY FrontEnd1/. ./
RUN npm run build -- --configuration=production
FROM nginx as runtime
COPY --from=build /app/dist/FrontEnd1 /usr/share/nginx/html
VOLUME /usr/share/nginx/html/assets/configuration/
The second angular app have exactly the same Dockerfile (except it is FrontEnd2). I deploy it using docker compose:
version: "3"
services:
proxy:
image: nginx
ports:
- "80:80"
- "443:443"
volumes:
- $STORAGE_FOLDER/nginx/conf/:/etc/nginx/conf.d/:rw
restart: always
public:
image: frontend1
creator:
image: frontend2
Then, I push the following nginx file to define the routes:
upstream creator {
server creator;
}
upstream public {
server public;
}
server {
listen 80;
listen [::]:80;
server_name localhost;
location /creator {
proxy_pass http://creator;
}
location / {
proxy_pass http://public;
}
}
It work perfectly for / route, but not for /creator route. The request comes with /creator part in the url to the frontend2 subnginx which return 404.
I've tried to add a trailing / :
location /creator {
proxy_pass http://creator/;
}
But I get a 304 in the sub nginx and nothing is returned.
I tried to add another trailing / on the location:
location /creator/ {
proxy_pass http://creator/;
}
And I get the same 304 with no result.
What is wrong with my code?