title: nginx cannot connect to uwsgi in other container with docker-compose
body: <p>I use docker-compose and there are two containers, one for uwsgi and one for nginx. But it seems that nginx fails to connect uwsgi.</p>
  <p>Here is the environment.</p>
  <pre><code>$ lsb_release -a
  No LSB modules are available.
  Distributor ID: Ubuntu
  Description:    Ubuntu 20.04.1 LTS
  Release:        20.04
  Codename:       focal
  $ docker --version
  Docker version 20.10.3, build 48d30b5
  $ docker-compose --version
  docker-compose version 1.24.0, build 0aa59064
  </code></pre>
  <p>Strangely, if I login to the nginx container and try to connect to the uwsgi manually, it succeeds as follows.</p>
  <pre><code>$ docker-compose ps --service
  python
  nginx
  $ docker-compose exec nginx /bin/bash
  # curl python:8001
  success!
  </code></pre>
  <p>However, when I try to access uwsgi via nginx, it fails.</p>
  <pre><code># curl localhost:8000/s
  &lt;html&gt;
  &lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;
  &lt;body bgcolor=&quot;white&quot;&gt;
  &lt;center&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/center&gt;
  &lt;hr&gt;&lt;center&gt;nginx/1.15.3&lt;/center&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>Here is my config. What is wrong with these? How can I fix this problem?</p>
  <p>docker-compose.yml</p>
  <pre><code>version: '3'
  services:
    nginx:
        image: nginx:1.15.3
        ports:
          - &quot;80:8000&quot;
        volumes:
          - ./nginx/nginx.conf:/etc/nginx/nginx.conf
          - ./python/uwsgi_params:/etc/nginx/uwsgi_params
          - .:/code
        depends_on:
          - python
    python:
        build: ./python
        ports:
          - &quot;8001:8001&quot;
        volumes:
          - ./proj:/code/proj
        command: bash -c &quot;ls -l &amp;&amp; cd proj &amp;&amp; pwd &amp;&amp; uwsgi --http :8001 --module fargate.wsgi --logto uwsgilog.txt&quot;
  </code></pre>
  <p>nginx/nginx.conf</p>
  <pre><code>events {
          worker_connections 768;
  }
  
  http {
          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;
          ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
          ssl_prefer_server_ciphers on;
          access_log /var/log/nginx/access.log;
          error_log /var/log/nginx/error.log;
          gzip on;
          include /etc/nginx/conf.d/*.conf;
          include /etc/nginx/sites-enabled/*;
  
      upstream django {
          server python:8001;
      }
      server {
          listen       8000; 
          server_name  localhost;
          root         /code/nginx/html;
          charset      utf-8;
          include /etc/nginx/default.d/*.conf;
          client_max_body_size 100M;
  
          location /static {
              alias /code/proj/static;
          }
          location ~ ^/s/(.*)$ {
          uwsgi_pass django;
          include /code/python/uwsgi_params;
          uwsgi_param SCRIPT_NAME /s;
          uwsgi_param PATH_INFO /$1;
          }
      }
  }
  </code></pre>
  <p>python/Dockerfile</p>
  <pre><code>FROM python:3.6
  ENV PYTHONUNBUFFERED 1
  RUN mkdir /code
  RUN mkdir /code/python
  WORKDIR /code
  ADD . /code/python/
  RUN pip install -r python/requirements.txt
  </code></pre>