Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

172
Visualizações
Connection betweetn docker containers

I am struggling with the connection of nginx and django (docker container)

My strategy is like this , run uwsgi http option and 8001 port. (not socket)

uwsgi --http :8001 --module myapp.wsgi --py-autoreload 1 --logto /tmp/mylog.log

then I confirmed wget http://127.0.0.1:8001 works.

but from, nginx, It can't connect somehow. (111: Connection refused) error

However from nginx wget http://django:8001 works.

How can I connect between containars

upstream django {
    ip_hash;
    server 127.0.0.1:8001;
}

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://127.0.0.1:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;

I am trying this config but, if I try this, my container doesn't launch.

log is like this 2020/03/24 08:24:04 [emerg] 1#1: upstream "django" may not have port 8001 in /etc/nginx/conf.d/app_nginx.conf:16

upstream django {
    ip_hash;
    server django:8001;
}

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://django:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;

my docker compose is very simple...

  nginx:
    image: nginx:1.13
    container_name: nginx
    ports:
      - "8000:8000"
    volumes:
      - ./nginx/conf:/etc/nginx/conf.d
      - ./nginx/uwsgi_params:/etc/nginx/uwsgi_params
      - ./nginx/static:/static
    depends_on:
      - django

Finally thanks to helps. my server works. final conf is like this below.

remove upstream and use name 'django' instead of 127.0.0.1

server {
    listen      8000;
    server_name 127.0.0.1;
    charset     utf-8;

    location /static {
        alias /static;
    }

    location / {
        proxy_pass  http://django:8001/;
        include     /etc/nginx/uwsgi_params;
    }
}

server_tokens off;
over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

If they run in different containers, 127.0.0.1 is not the correct IP; use the name of the other container, e.g.

proxy_pass http://django:8001;

so Docker's internal DNS can route things.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda