Expose Node.js API on docker with Nginx

I am new to docker and I have a machine running it where im hosting a Laravel website and a Node.js API, im using Nginx to configure the web server but im having trouble to be able to reach my node API from the outside of the machine.

This is my default.conf file:

server {
 listen 80;
 index index.php index.html;
 server_name app.mydomain.com;
 root /var/www/html/public;

 location / {
  try_files $uri $uri/ /index.php?$query_string;

 location ~\.php$ {
  try_files $uri =404;
  fastcgi_split_path_info ^(.+\.php)(/.+)$;
  fastcgi_pass php:9000;
  fastcgi_index index.php;
  include fastcgi_params;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  fastcgi_param PATH_INFO $fastcgi_path_info;

server {
    listen 80;
    server_name api.mydomain.com;

    location / {
        proxy_pass http://localhost:3000;

My node.js api dockerfile:

FROM node:16

# Create app directory
WORKDIR /usr/src/app

# Install app dependencies
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm@5+)
COPY ./media-cloud-node/package*.json ./

RUN npm install

# Bundle app source
COPY ./media-cloud-node .

CMD [ "npm", "start" ]

Im using docker-compose to run all the requested images, here is the nginx and node parts from the docker-compose.yml file:

version: '3.8'

   context: .
   dockerfile: nginx.dockerfile
   - 80:80
   - ./src:/var/www/html
   - php
   context: .
   dockerfile: node.dockerfile
   - ./media-cloud-node:/usr/src/app

The laravel application is working as expected, however the node.js API is responding with a "502 Bad Gateway" when i make a request to it. I cant figure out why this happens:

enter image description here

Here is the docker ps command output:

enter image description here

If anyone can help would be great, just tell me if you need any extra information.

Thanks in advance!

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum