0

I'm deploying a django application in elastic beanstalk and docker using nginx and uwsgi.

Below is the Dockerfile:

FROM ubuntu:14.04

MAINTAINER Nijo James

# Update packages
RUN apt-get update -y

#Install python Setuptools
RUN apt-get install -y python python-dev python-setuptools python-software-properties
RUN apt-get install -y libpq-dev  
RUN apt-get install -y supervisor
RUN apt-get install -y libxml2-dev libxslt1-dev zlib1g-dev
RUN apt-get install -y build-essential libssl-dev libffi-dev 

#TO install pillow
RUN apt-get install -y libjpeg-dev 


# update packages after adding nginx repository
RUN apt-get update
# install latest stable nginx
RUN apt-get install -y nginx

#setup redis-server
RUN apt-get install -y redis-server

#Install pip 
RUN easy_install pip 

# Install uwsgi
RUN pip install uwsgi

# copy the contents of this directory over to the container at location /src
ADD . /home/docker/src/

# run pip install
RUN pip install -r /home/docker/src/server/requirements.txt

# Customize configurations
RUN echo "daemon off;" >> /etc/nginx/nginx.conf

RUN rm /etc/nginx/sites-enabled/default

RUN rm /etc/nginx/sites-available/default
RUN ln -s /home/docker/src/server/nginx-app.conf /etc/nginx/sites-enabled/

RUN ln -s /home/docker/src/server/supervisor-app.conf /etc/supervisor/conf.d/

RUN mkdir -p /home/docker/src/server/logs/

EXPOSE  80

#Run command
cmd ["/home/docker/src/server/start.sh"]

But when I try to access it via web I'm getting 502 Bad Gateway.

And I'm getting the same error when I try to cURL the Docker IP.

Elastic Beanstalk error log has the following errors:

[error] 29386#0: *1986 connect() failed (111: Connection refused) while connecting to upstream, client: 172.31.43.60, server: , request: "GET / HTTP/1.1", upstream: "http://[dockerip]:80/", host: "xxxxxxxxxxxxx.elasticbeanstalk.com"

here is my nginx config:

upstream django
{

 server unix:/tmp/api.sock; # for a file socket

}

server 
{

listen      80 default_server;

charset     utf-8;

# max upload size
client_max_body_size 4G;   # adjust to taste


location / {
    uwsgi_pass  django;
    include     /home/docker/src/server/uwsgi_params; # the uwsgi_params file you installed
}

sendfile off;
access_log /home/docker/src/server/logs/nginx-access.log;
error_log /home/docker/src/server/logs/nginx-error.log;

uwsgi error log from inside the docker:

current working directory: /home/docker/src/server

detected binary path: /usr/local/bin/uwsgi

!!! no internal routing support, rebuild with pcre support !!!

uWSGI running as root, you can use --uid/--gid/--chroot options

* WARNING: you are running uWSGI as root !!! (use the --uid flag) * chdir() to /home/docker/src/server/

4
  • The error you are seeing in the error log is coming from Nginx - it's unable to connect to wherever you've configured it to proxy to. Could you update your question with your Nginx configuration within /home/docker/src/server/nginx-app.conf? Jul 4, 2016 at 14:23
  • @brendonofficial i have nginx config file and uwsgi error log
    – Nijo
    Jul 4, 2016 at 16:37
  • @brendonofficial i can ping to the docker ip inside eb ssh terminal. But when i try to curl dockerip, i'm getting 502 bad Gateway error.
    – Nijo
    Jul 5, 2016 at 4:40
  • can anybody help
    – Nijo
    Jul 5, 2016 at 11:50

0

You must log in to answer this question.

Browse other questions tagged .