i have problem with setup my nginx. I was able to start all "apps/" modules inside docker. But reverse proxy still doesn't work as expected.
Story: Nx directories:
/ apps
/ test-1 (Nuxt)
/ test-2 (Nuxt)
/ test-3 (Nuxt)
docke-compose.yml:
version: '3'
services:
nginx:
image: nginx:latest
restart: always
container_name: local_nginx
volumes:
- ./nginx/reverse_proxy.conf:/etc/nginx/nginx.conf
ports:
- 8080:8080
networks:
- my_net
event-module:
extends:
file: default.service.yml
service: start_module
command: npm run test-1-module-local
ports:
- 3001:3001
container_name: local-test-1-module
networks:
- my_net
depends_on:
- nginx
portal-module:
extends:
file: default.service.yml
service: start_module
command: npm run test-2-module-local
ports:
- 3002:3002
container_name: local-test-2-module
networks:
- my_net
depends_on:
- nginx
user-module:
extends:
file: default.service.yml
service: start_module
ports:
- 3003:3003
container_name: local-test-3-module
command: npm run test-3-module-local
networks:
- my_net
depends_on:
- nginx
volumes:
mono-node-modules: null
networks:
my_net:
driver: "bridge"
default.service.yml:
version: '3'
services:
start_module:
restart: always
build:
context: .
dockerfile: Dockerfile
volumes:
- ./:/nuxt-app
- mono-node-modules:/nuxt-app/node_modules
Dockerfile:
FROM node:16.20.1
RUN mkdir -p /nuxt-app
WORKDIR /nuxt-app
COPY . .
RUN npm install
CMD ["npm", "run", "test-1-module-local"]
reverse_proxy.conf:
events {
worker_connections 1024;
}
http {
upstream local-test-1-module {
server 0.0.0.0:3001;
}
upstream local-test-2-module {
server 0.0.0.0:3002;
}
upstream local-test-3-module {
server 0.0.0.0:3003;
}
server {
listen 8080;
location / {
proxy_redirect off;
proxy_pass http://local-test-1-module;
}
location /test-2/ {
proxy_pass http://local-test-2-module;
}
location /test-3/ {
proxy_pass http://local-test-3-module;
}
}
}
I would like to run every module on the same url like http://localhost:8080/
with module name after base url example:
http://localhost:8080/test-1
for test-1http://localhost:8080/test-2
for test-2http://localhost:8080/test-3
for test-3
At the moment all of dem starts at:
http://localhost:3001
http://localhost:3002
http://localhost:3003
Is there any chance to make it? Thank you for you time and help in advice.