title: Nginx error in a docker container
body: <p>I have a flask app that I'm trying to run in a docker container. Docker-compose build and docker-compose up both run fine, but when I go to <em>localhost</em> I'm getting 502 Bad Gateway from nginx. Here is there nginx error log</p>
  
  <pre><code>2018/05/06 14:06:37 [error] 10#10: *12 connect() failed (111: Connection refused) while connecting to upstream, client: 10.8.5.79, server: servername.com, request: "GET /favicon.ico HTTP/1.1", upstream: "http://10.21.50.9:8000/favicon.ico", host: "servername.com", referrer: "http://servername.com/"
  10.8.5.79 - - [06/May/2018:14:06:37 +0000] "GET /favicon.ico HTTP/1.1" 502 575 "http://servername.com/" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36" "-"
  </code></pre>
  
  <p>My nginx.conf file looks like this </p>
  
  <pre><code>user nginx;
  worker_processes auto;
  error_log /var/log/nginx/error.log;
  pid /run/nginx.pid;
  
  include /usr/share/nginx/modules/*.conf;
  
  events {
  worker_connections 1024;
  }
  
  http {
      log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                    '$status $body_bytes_sent "$http_referer" '
                    '"$http_user_agent" "$http_x_forwarded_for"';
  
  access_log  /var/log/nginx/access.log  main;
  
  sendfile            on;
  tcp_nopush          on;
  tcp_nodelay         on;
  keepalive_timeout   65;
  types_hash_max_size 2048;
  
  include             /etc/nginx/mime.types;
  default_type        application/octet-stream;
  
  include /etc/nginx/conf.d/*.conf;
  
  server {
      listen       80 default_server;
      #listen       [::]:80 default_server;
      server_name  _;
      root         /usr/share/nginx/html;
  
      # Load configuration files for the default server block.
      include /etc/nginx/default.d/*.conf;
  
      location / {
          proxy_pass http://127.0.0.1:8080;
      proxy_redirect off;
      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;
  }
  
  
      error_page 404 /404.html;
          location = /40x.html {
      }
  
      error_page 500 502 503 504 /50x.html;
          location = /50x.html {
      }
  }
  
  }
  </code></pre>
  
  <p>Is there something simple I'm overlooking in this conf? Or perhaps another reason the nginx isn't working?</p>
  
  <p>Edit added docker-compose.yml file</p>
  
  <p>version: '2'</p>
  
  <pre><code>services:
   web:
     restart: always
     build: ./web
     expose:
       -"8000"
     volumes:
       - /usr/src/app/project/static
     command: /usr/local/bin/gunicorn -w 2 -b :8000 project:app
  
   nginx:
     restart: always
     build: ./nginx
     ports:
       - "80:80"
     volumes:
       - /www/static
     volumes_from:
       - web
     depends_on:
       - web
  </code></pre>