The original post: /r/nginx by /u/nameless9346 on 2024-07-06 07:46:24.

Hello everybody,

I nedd a community Help.

I’m new of Docker contest and i start study it yesterday.

I did a monorepo with Nx with 2 projects:

  • Node with Fastify for BE
  • Angular for FE

I did 2 docker file, they work perfectly becouse when I build this 2 dockerfile They work perfectly, on port 3000 i see my BE and on port 5000 i see FE, but for prevent CORS (becouse this app will be deployed on my LAN) error i need that this systems stay on like domain and for it I created this docker-compose file:

version: '3'
services:
  node_app:
    image: my-finance-api
    container_name: node_app
    ports:
      - "3100:3000"
    networks:
      - my_network

  angular_app:
    image: my-finance-app
    container_name: angular_app
    ports:
      - "5100:5000"
    networks:
      - my_network

  nginx:
    image: nginx:latest
    container_name: nginx_proxy
    ports:
      - "7000:7000"
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf
    networks:
      - my_network

networks:
  my_network:
    driver: bridge

This is a nginx.cof

events { }

http {
    server {
        listen 7000;

        location /app {
            proxy_pass http://angular_app:5000;
            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;
        }
    }
}

The problem is thath:

  • On localhost:7000/app i see only withe page and every http request return me 404 (for file css, js, ecc ecc)

How can i resolve it?

P.S. Sorry for my bad englis :)