title: Redirect /api requests to port 3000 using NGINX (Docker)
body: <p>I want to redirect the requests to the /api to the node app running on localhost:3000 using NGINX</p>
  
  <p>I'm trying to redirect the requests using proxy_pass</p>
  
  <pre><code>server {
     listen 80;
     server_name  localhost;
  
     root /var/www/mydomain/html;
     index index.html index.htm;
  
     location /api {
         proxy_pass http://127.0.0.1:3000/;
     }
  }
  </code></pre>
  
  <p>If I access localhost in my browser I see the frontend application, so that's correct.</p>
  
  <p>If I hit <a href="http://127.0.0.1:3000" rel="nofollow noreferrer">http://127.0.0.1:3000</a> (or localhost:3000) I get a response from the node API, so that's correct.</p>
  
  <p>But when I try to access localhost/api I get the following error:</p>
  
  <blockquote>
    <p>[error] 6#6: *3 connect() failed (111: Connection refused) while connecting >to upstream, client: 172.18.0.1, server: localhost, request: "GET /api >HTTP/1.1", upstream: "<a href="http://127.0.0.1:3000/" rel="nofollow noreferrer">http://127.0.0.1:3000/</a>", host: "localhost"</p>
  </blockquote>
  
  <p>EDIT:</p>
  
  <p>I'm using a docker-compose to manage the services:</p>
  
  <pre><code>services:
  
    nginx:
      container_name: nginx-local
      build:
        context: .
        dockerfile: ./nginx.dev.dockerfile
      volumes:
        ...
      ports: 
        - '80:80'
      networks:
        - local-network
  
    node:
      container_name: node-api
      build:
        context: ./api
        dockerfile: .docker/node.dockerfile
      ports: 
        - '3000:3000'
      networks:
        - local-network
  </code></pre>