title: resolving simple containerized nginx : bad gateway
body: <p>I have a nginx container supposed to serve a flask+gunicorn container but i get a <code>&quot;502 bad gateway&quot;</code> error even if the flask+gunicorn container is working properly.</p>
  <p>Could you help me understand why this is happening ?
  (I have tried to remove the <code>mynet</code> network but it's the same)</p>
  <p>This is my nginx.conf:</p>
  <pre><code>server {
      listen 80;
      server_name localhost; 
      
      location / {
          proxy_pass http://app:4000;
          proxy_set_header Host $host;
          proxy_set_header X-Forwarded-Host $host;
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          client_max_body_size 20M;
        } 
      }
  </code></pre>
  <p>This is my docker-compose.yml :</p>
  <pre><code>---
  version: '3.7'
  services:
    nginx:
      build:
        context: .
        dockerfile: ./nginx/Dockerfile
      restart: always
      ports:
        - 80:80
      depends_on:
        - app
      networks:
        - mynet
    app:
      container_name: app
      build:
        context: .
        dockerfile: ./app/Dockerfile
      volumes:
        - app:/app
      ports:
        - 4000:5000
      networks:
        - mynet
  
  
  volumes:
    app:
      name: app
  networks:
    mynet:
  </code></pre>
  <p>And the app dockerfile</p>
  <pre><code>FROM python:3.8-slim-buster
  RUN apt-get update \
    # dependencies for building Python packages
    &amp;&amp; apt-get install -y build-essential netcat\
    # cleaning up unused files
    &amp;&amp; apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
    &amp;&amp; rm -rf /var/lib/apt/lists/*
  RUN adduser --home /app --system --group kr1p
  WORKDIR /app
  COPY --chown=kr1p:kr1p app .
  RUN pip install -r requirements.txt 
  USER kr1p
  ENV PYTHONUNBUFFERED=1
  CMD gunicorn
  </code></pre>
  <p>And the nginx Dockerfile:</p>
  <pre><code>FROM nginx:1.21.6-alpine
  RUN rm /etc/nginx/conf.d/default.conf
  COPY ./nginx/nginx.conf /etc/nginx/conf.d
  CMD [&quot;nginx&quot;, &quot;-g&quot;, &quot;daemon off;&quot;]
  </code></pre>