title: How do I access a server on localhost with nginx docker container?
body: <p>I'm trying to use a dockerized version of nginx as a proxy server for my node (ExpressJS) application. Without any configuration to nginx and publishing port 80 for the container, I am able to see the default nginx landing page. So I know that much is working.</p>
  
  <p>Now I can mount my sites-enabled directory that contains the configuration for <code>proxy_pass localhost:3000</code>. I have my node application running locally (not in any Docker container) and I can access it via port 3000 (i.e. <code>localhost:3000</code>). However, I would assume that with nginx container running, mapped to port 80, and proxying my localhost:3000, that I would be able to see my <em>very</em> simple (hello world) application. Instead I receive a 502. </p>
  
  <p>Do I need to pass something into docker? Is this likely a nginx configuration error? Here is my nginx configuration:</p>
  
  <pre><code>server {
    listen 0.0.0.0:80;
    server_name localhost;
  
    location / {
      proxy_pass http://localhost:3000;
    }
  }
  </code></pre>
  
  <p>I have tried using <a href="https://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach?rq=1">this question</a> but it did not seem to help. That is unless I'm doing something completely wrong.</p>