Srinath Ganesh
Srinath Ganesh

Reputation: 2558

Docker uWSGI - NGINX: uWSGI ok but NGINX is a 502

I configured my django-uwsgi-nginx using docker compose with the following files.

From browser "http://127.0.0.1:8000/" works fine and gives me the django default page

From browser "http://127.0.0.1:80" throws a 502 Bad Gateway


dravoka-docker.conf

upstream web {
    server 0.0.0.0:8000;
}

server {
    listen 80;
    server_name web;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        alias "/dravoka-static/";
    }

    location / {
        include         uwsgi_params;
        proxy_pass      http://web;
    }
}

nginx/Dockerfile

FROM nginx:latest
RUN echo "---------------------- I AM NGINX --------------------------"
RUN rm /etc/nginx/conf.d/default.conf
ADD sites-enabled/ /etc/nginx/conf.d
RUN nginx -t

web is just from "django-admin startproject web"

docker-compose.yaml

version: '3'

services:

  nginx:
    restart: always
    build: ./nginx/
    depends_on:
      - web
    ports:
      - "80:80"

  web:
    build: .
    image: dravoka-image
    ports:
      - "8000:8000"
    volumes:
      - .:/dravoka
    command: uwsgi /dravoka/web/dravoka.ini

Dockerfile

# Ubuntu base image
FROM ubuntu:latest
# Some installs........
EXPOSE 80

Upvotes: 1

Views: 857

Answers (1)

Pratik Shah
Pratik Shah

Reputation: 1852

When you say from the docker instance , you are running curl from with in the container ?? or you are running the curl command from your local ?

if you are running it from your local , update your docker-compose's web service to following

...
  web:
    build: .
    image: dravoka-image
    expose:
      - "8000:8000"
    volumes:
      - .:/dravoka
    command: uwsgi /dravoka/web/dravoka.ini

and try again.

Upvotes: 1

Related Questions